c# webbrowser cannot read cyrillic

2019-09-06 14:19发布

问题:

When I write

richTextBox1.Text = wb.DocumentText;

Its showing the russian letters like that ������

What I can do?

回答1:

Using WebClient, you can set the encoding in order to retrieve the HTML and get it encoded correctly.

Untested example:

var wc = new WebClient();
wc.Encoding = Encoding.GetEncoding("windows-1251");

richTextBox1.Text = wc.DownloadString(myURL);


回答2:

You must install the cyrilic fonts to your browser in order to see charachters other then the standard types.

If its a desktop app you must look for if the required fonts exist in your font folder.

Or be sure that all your encoding meets the UTF-8 standard.