且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何转义HTML字符?在.NET中-& gt;& amp; quot;

更新时间:2022-12-04 20:04:01

如果必须执行两次,则说明您对源字符串进行了双重编码,因此必须对它进行双重解码才能返回到原始(未编码))字符串.

If you have to do it twice, then you have double encoded your source string, and so you have to double decode it to get back to the original (unencoded) string.

您可以将 System.Web.HttpUtility.HtmlEncode() HtmlDecode()用于这些目的.

You can use System.Web.HttpUtility.HtmlEncode() and HtmlDecode() for these purposes.