【问题标题】:How to convert from ISO-8859-1 to UTF-8?如何从 ISO-8859-1 转换为 UTF-8?
【发布时间】:2020-10-21 09:37:24
【问题描述】:

我需要将 charset = iso-8859-1 中的 html 文件转换为 UTF-8,您能帮帮我吗?

这是我的代码:

字符串 converHtml = File.ReadAllText(html); 编码 iso = Encoding.GetEncoding("windows-1252"); 编码 utf8 = Encoding.UTF8; byte[] isoBytes = iso.GetBytes(converHtml); byte[] utf8Bytes = Encoding.Convert(utf8, iso, isoBytes); 字符串味精 = utf8.GetString(utf8Bytes); 味精 = HttpUtility.HtmlDecode(味精); 返回味精;

【问题讨论】:

标签: c#


【解决方案1】:

感谢 Klaus Gütter、Alexei Levenkov,它对我有用。 这是我的代码:

StreamReader sr = new StreamReader(html, Encoding.GetEncoding(28591)); var ags = sr.ReadToEnd();

【讨论】:

    猜你喜欢
    • 2011-05-26
    • 2011-09-26
    • 1970-01-01
    • 2011-08-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-05
    • 2014-08-29
    • 2014-04-30
    相关资源
    最近更新 更多