My question is simple. I searched a little online, but could not find a quick way to unescape HTML text in a string.
For example:"< > &"
should be returned to "< > &" as a string.
Is there a quick way, or do I have to write my own unescaper?
use System.Web.HttpUtility.HtmlDecode
or System.Net.WebUtility.HtmlDecode
var decoded = HttpUtility.HtmlDecode("< > &");
If you're using .NET 4.5 then you can use the HttpUtility.HtmlDecode
method.
Usman Younas
HttpUtility.UrlDecode("Your escaped String", System.Text.Encoding.Default);
来源:https://stackoverflow.com/questions/15955646/decode-html-escaped-characters-back-to-normal-string-in-c-sharp