C# webclient中文乱码问题解决方法


webclient在调用DownloadData或者DownloadString的时候请求回来的数据出现乱码问题,解决办法如下:

1、设置webclient的编码格式为目标编码格式

http://m.weather.com.cn/data/101110101.html");
string rr = Encoding.GetEncoding("utf-8").GetString(pageData);

总结下来,还是编码的问题,不论哪种方法,设置好编码即可。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3