10

I've a string for example like this:

Col´gio

How can I convert it to:

Colégio

Without having to do a replace for all the html codes

Bruno Cruz
  • 137
  • 1
  • 3
  • 9
  • 1
    See http://stackoverflow.com/questions/1144535/c-sharp-htmlencode-from-class-library or http://stackoverflow.com/questions/122641/how-can-i-decode-html-characters-in-c. There are also plenty of other instances of this - you need to Html DECODE the string. – dash May 24 '12 at 10:21

3 Answers3

17
System.Web.HttpUtility.HtmlDecode("Col´gio");
L.B
  • 114,136
  • 19
  • 178
  • 224
9

Just for completion:

If you are using .NET 4.0+ you can also use WebUtility.HtmlDecode

julianox
  • 758
  • 1
  • 7
  • 9
2
SecurityElement securityElement = System.Security.SecurityElement.FromString("<test>H&amp;M</test>");
string unescapedText = securityElement.Text;
Console.WriteLine(unescapedText); // Result: H&M
David Brabant
  • 41,623
  • 16
  • 83
  • 111