开发者

Handle special chars

开发者 https://www.devze.com 2023-02-25 01:20 出处:网络
When I do WebClient wc = new WebClient(); string content = wc.DownloadString(url); File.WriteAllTe开发者_StackOverflow社区xt(path, content);

When I do

WebClient wc = new WebClient();
string content = wc.DownloadString(url);
File.WriteAllTe开发者_StackOverflow社区xt(path, content);

And I open the file in path with Internet Explorer, special characters like ó apear like ó.

Is there a way for interpreting correctly those characters?


You're downloading it in whatever content encoding is specified, but then saving it as UTF-8. If you want to save it to disk anyway, I suggest you use WebClient.DownloadFile directly instead. Then so long as the encoding is also specified in the HTML (correctly) it should be okay.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号