Converting HTML entities to Unicode Characters in C#

前端 未结 6 2088
心在旅途
心在旅途 2020-12-15 15:23

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\'

6条回答
  •  臣服心动
    2020-12-15 16:19

    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).

    Usage:

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

提交回复
热议问题