[英]Decode HTML escaped characters back to normal string in C#
我的問題很簡單。 我在網上搜索了一下,但找不到快速瀏覽字符串中HTML文本的方法。
例如:
"< > &"
應該作為字符串返回“<>&”。
有快速的方式,還是我必須寫自己的unescaper?
使用System.Web.HttpUtility.HtmlDecode
或System.Net.WebUtility.HtmlDecode
var decoded = HttpUtility.HtmlDecode("< > &");
如果您使用的是.NET 4.5,則可以使用HttpUtility.HtmlDecode
方法。
HttpUtility.UrlDecode("Your escaped String", System.Text.Encoding.Default);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.