Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping HTML characters with UTF-8?

Tags:

html

encoding

If my site is using UTF-8, is there any advantage/disadvantage to still escaping HTML characters? e.g. Using "&" instead of just "&"? What's the best practice?

like image 304
Arturo Molina Avatar asked Dec 05 '11 22:12

Arturo Molina


1 Answers

You still need to escape characters that have a special meaning in HTML, like <, >, &, to avoid parser ambiguities/invalid syntax. That has nothing to do with the encoding. You don't need to escape every non-ASCII character though, like "ö" to &ouml;, since you can natively represent them in the UTF-8 encoding.

like image 187
deceze Avatar answered Sep 27 '22 19:09

deceze