Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I decode HTML characters in C#?

Tags:

c#

I have email addresses encoded with HTML character entities. Is there anything in .NET that can convert them to plain strings?

like image 764
Vasil Avatar asked Sep 23 '08 18:09

Vasil


People also ask

What does Httputility Htmldecode do?

Converts a string that has been HTML-encoded for HTTP transmission into a decoded string. Converts a string that has been HTML-encoded into a decoded string, and sends the decoded string to a TextWriter output stream.


2 Answers

You can use HttpUtility.HtmlDecode

If you are using .NET 4.0+ you can also use WebUtility.HtmlDecode which does not require an extra assembly reference as it is available in the System.Net namespace.

like image 150
Quintin Robinson Avatar answered Oct 13 '22 22:10

Quintin Robinson


On .Net 4.0:

System.Net.WebUtility.HtmlDecode() 

No need to include assembly for a C# project

like image 38
Indy9000 Avatar answered Oct 13 '22 23:10

Indy9000