Skip to main content
 首页 » 编程设计

c# htmlDecode 实体数大于 127

2024年02月13日14myhome

你好,我想解码 html 实体,但是当实体数大于 127 时我遇到了问题。

我正在使用 WebUtility.HtmlDecode

示例:

class Program 
{ 
 
    static void Main(string[] args) 
    { 
        string text = "`°•»ZEЯO«•°´"; 
        Console.WriteLine(WebUtility.HtmlDecode(text)); 
        Console.ReadKey(); 
    } 
}  

Output : `°»ZE?O«°´ and not : `°•»ZEЯO«•°´

问题是实体没有正确解码。

Я 

我想知道如何解码它,我做了很多搜索但找不到解决方案...

预先感谢您的帮助。

请您参考如下方法:

问题不在于 WebUtility.HtmlDecode - 如果您单步执行,您将看到在 Visual Studio 中的表现形式很好。问题是默认情况下,控制台无法显示 Unicode。