C#获取网站源代码数据中文乱码??
我的方法如下,获取url为http://www.sohu.com就出现汉字乱码?对于日文登就更不用说了
public string WebClientGetSource(string url)
{
string source="";
try
{
WebClient client=new WebClient();
Stream data=client.OpenRead(url);
StreamReader reader=new StreamReader(data,Encoding.Unicode);
string strTemp="";
while((strTemp=reader.ReadLine())!=null)
{
source+=strTemp+"\r\n";
}
}
catch(WebException exp)
{
MessageBox.Show(exp.Message,"Exception");
}
return source;
}