HtmlEncode UTF-8
-
05-07-2019 - |
Question
I'm using Server.HtmlEncode on a utf-8 string in asp-classic, which works fine until there are some accents in the string e.g. Rüstü Recber, which appears as Rüstü Recber (Rüstü Recber in the source).
I've tried setting the Response.Charset property to utf-8 but this doesn't make any difference.
Solution
Update (Solved): Adding <%@CODEPAGE=65001%> at the start of the page corrected the problem (http://technet.microsoft.com/en-us/library/bb742422.aspx)
Many thanks for all of the suggestions.
OTHER TIPS
Check if the editor you are using to view the text is set to show utf-8.
Did you try to UrlEncode as well?
Are you sure that the string is correct before it is passed to HtmlEncode ? It looks like the string might be encoded wrong before it is passed to HtmlEncode.
Try to encode a string that you know is correct, and see if it is encoded correctly.