您可以使用 HtmlEncode
要编码字符串,然后您可以使用 HtmlDecode
返回原始值:
string x = "éí&";
string encoded = System.Web.HttpUtility.HtmlEncode(x);
Console.WriteLine(encoded); //éí&
string decoded = System.Web.HttpUtility.HtmlDecode(encoded);
Console.WriteLine(decoded); //éí&
通过更新,您只需要解码字符串:
String decoded = System.Web.HttpUtility.HtmlDecode("November is Fruit's Fresh.");
Console.WriteLine(decoded); //November is Fruit's Fresh.