Remy Remy - 11 months ago 105
C# Question

Converting HTML entities to Unicode Characters in C#

I found similar questions and answers for Python and Javascript, but not for C# or any other WinRT compatible language.

The reason I think I need it, is because I'm displaying text I get from websites in a Windows 8 store app. E.g.

should become

Or is there a better way? I'm not displaying websites or rss feeds, but just a list of websites and their titles.

Answer Source

I recommend using System.Net.WebUtility.HtmlDecode and NOT HttpUtility.HtmlDecode.

This is due to the fact that the System.Web reference does not exist in Winforms/WPF/Console applications and you can get the exact same result using this class (which is already added as a reference in all those projects).


string s =  System.Net.WebUtility.HtmlDecode("é"); // Returns é