goldengel
goldengel

Reputation: 611

When receiving chinese string, I only get unusable characters

I am using an textreader from the internet to read Chinese text, but I'm receiving incorrect letters.

For example, I get back 您好 ï¼ instead of 轉注字. Also, if I parse German strings, I receive Sie können instead of Sie können.

This is the original string from website:

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Sie können einige Blumen auswählen</string>

It is UTF-8 encoded. How do I resolve this encoding issue?

Regards

Upvotes: 1

Views: 240

Answers (1)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174299

Try to initialize your TextReader with the appropriate encoding:

using(var reader = new StreamReader(stream, Encoding.UTF8)
{
    // read the text
}

Upvotes: 2

Related Questions