C#WebUtility.HtmlDecode返回“?”

时间:2013-10-16 14:43:46

标签: c# console-application

String Text = "This is example ”Text”";
Text = WebUtility.HtmlDecode(Text);
System.IO.File.WriteAllText(@"c:\x.txt", Text, Encoding.ASCII);

正确输出:

This is example ”Text”

输出x.txt:

This is example ?Text?

1 个答案:

答案 0 :(得分:0)

您可以使用“iso-8859-1”编码:

更改

System.IO.File.WriteAllText(@"c:\x.txt", Text, Encoding.ASCII);

System.IO.File.WriteAllText(@"c:\x.txt", Text, Encoding.GetEncoding(28591));