返回的html源码中的所有中文都是乱码..这是真么一回事啊,求高手指点啊!
string s = "苹果";
s = System.Web.HttpUtility.UrlEncode(s,Encoding.UTF8);
string urlToCrawl=" http://www.baidu.com/s?wd=" + s;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlToCrawl);
req.Method = "GET";
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
string htmlCharset = "gb2312";
Encoding htmlEncoding = Encoding.GetEncoding(htmlCharset);
StreamReader sr = new StreamReader(resp.GetResponseStream(), htmlEncoding);
string respHtml = sr.ReadToEnd();
rtbExtractedHtml.Text = respHtml;
这是我的源码,但是最后返回来的html源码中的所有中文都是乱码..这是真么一回事啊,求高手指点啊!
------解决方案--------------------string htmlCharset = "gb2312";
=>
string htmlCharset = "utf-8";
------解决方案--------------------顶楼上的~~~~~~~~~~~~~~
------解决方案--------------------顶楼上。。