2

I am using a WebBrowser control in my project. My code example is below:

webBrowser1.Navigate("Web Site goes here");

The web browser is navigating the Google website, however I can not see the Turkish characters.

Therefore I use:

webBrowser1.Document.Encoding = "UTF-8"

However the problem still continues. Any idea to solve this?

ckittel
  • 6,478
  • 3
  • 41
  • 71
julia
  • 61
  • 2
  • 2
  • 4

2 Answers2

4
StreamReader sr = new StreamReader(this.webBrowser1.DocumentStream, Encoding.GetEncoding("UTF-8"));
string source = sr.ReadToEnd();

or you can try "iso-8859-9" for encoding. this should do it.

Yigit
  • 183
  • 2
  • 9
  • ISO-8859-9 is for Turkish only. Then, he won't be able to show English characters. – Chinmoy Nov 05 '11 at 13:10
  • @r3st0r3 So he has to parse the beginning of the document, if there is a "" block he can use the value of "charset" field as the required encoding scheme. Problem? – Yigit Nov 11 '11 at 16:23
2

This was really helpful.

I was stuck with this for a while and managed to get my code to work

using (FileStream fs = new FileStream(urlfile, FileMode.Create))
                        {

                            using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
                            {
                                sw.Write(datasetHtmlreplacements);
                                sw.Close();
                            }
                        }
Greg
  • 47
  • 7