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?
Unescape HTML Entities with a Text Area One way to unescape HTML entities is to put our escaped text in a text area. This will unescape the text, so we can return the unescaped text afterward by getting the text from the text area. We have an htmlDecode function that takes an input string as a parameter.
HtmlDecode(String, TextWriter)Converts a string that has been HTML-encoded into a decoded string, and sends the decoded string to a TextWriter output stream.
HtmlEncode(Object)Converts an object's string representation into an HTML-encoded string, and returns the encoded string. public: static System::String ^ HtmlEncode(System::Object ^ value); C# Copy.
use System.Web.HttpUtility.HtmlDecode
or System.Net.WebUtility.HtmlDecode
var decoded = HttpUtility.HtmlDecode("< > &");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With