问题
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?
回答1:
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.
回答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();
}
}
来源:https://stackoverflow.com/questions/7281137/webbrowser-encoding-problem