Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with HttpUtility.HtmlEncode with other language characters

I was trying to encode the HTML special characters like ', ", <,> etc with HttpUtility.HtmlEncode. But I noticed this is also encoding french characters like (é) to é and now é is getting displayed as it is on my HTML page. I don't want this I just want to encode ', ", <,> and few other characters.

like image 784
Rocky Singh Avatar asked Apr 14 '26 21:04

Rocky Singh


1 Answers

Should those characters look differently? Why is it a problem if they are replaced? This is by design. You can take a look at this question to see longer discussion. Unless your users can't properly see text you are displaying, you shouldn't mess with this, for security/compatibility reasons.

HtmlUtility seems to encode several classes of characters, among which ISO-8859-1 character set If you still don't want a specific character to be encoded, you are forced to use string.Replace() for this purpose.

like image 58
Nikola Radosavljević Avatar answered Apr 17 '26 10:04

Nikola Radosavljević