webbrowser encoding problem

China☆狼群 提交于 2020-01-02 18:45:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!