处理特殊字符

时间:2011-04-16 10:07:20

标签: c# stream webclient

当我这样做时

WebClient wc = new WebClient();
string content = wc.DownloadString(url);
File.WriteAllText(path, content);

我使用Internet Explorer在path中打开文件,像³这样的特殊字符,如³

有没有办法正确解释这些角色?

1 个答案:

答案 0 :(得分:4)

您正在以指定的任何内容编码下载它,但将其保存为UTF-8。如果您想将其保存到磁盘,我建议您直接使用WebClient.DownloadFile。然后,只要编码在HTML中指定(正确),它应该没问题。