ASP.NET Server.HtmlEncode Wont Encode €

I know that the EUR symbol (€) is encoded as € in HTML, but System.Web.HttpUtility.HtmlEncode("€") does not encode it at all. Does anyone know why this is?

+4
source share
1 answer

HttpUtility.HtmlEncode only encodes characters that are "reserved" in HTML. For this list, see the first table on this page: http://www.w3schools.com/tags/ref_entities.asp .

In other words, only those characters that may conflict with the basic structure of HTML (for example, <,>, "etc.). No other characters should be encoded if the encoding of the transmitted bytes is defined correctly (for example, using and declaring UTF- 8).

+6
source

Source: https://habr.com/ru/post/1310227/


All Articles