Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In .net, is there an opposite function to Server.HTMLEncode()?

Tags:

asp.net

.Net's Server.HTMLEncode() is the very helpful function that takes an HTML string and replaces special characters with their entity equivalents - "<" becomes &lt ; and so forth.

Is there a (built-in) function that does the reverse? There doesn't seem to be, and I am incredulous. While I could certainly write my own (and have in the past) Server.HTMLEncode has all kinds of cool handling for different string encodings and high-level unicode characters that I would really not have crash my hand-rolled decoder in a year's time.

What do other people do when they need the plain HTML back?

Update: To answer the first batch of questions, I present the MSDN article on the Server object, which has Encode but no Decode... I'm as amazed as anyone.

Update2: as several alert readers have pointed out, the docs I was looking at were for classic ASP, not ASP.Net. Thanks guys, that's an important MSDN safety tip.

like image 813
Electrons_Ahoy Avatar asked Jul 20 '26 00:07

Electrons_Ahoy


2 Answers

Server.HtmlDecode ....

like image 138
Sergio Avatar answered Jul 22 '26 00:07

Sergio


You didn't see a HtmlDecode in the same place you found the HtmlEncode?

like image 44
Cristian Libardo Avatar answered Jul 22 '26 01:07

Cristian Libardo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!