Mobile app version of vmapp.org
Login or Join
Karen161

: Why use HTML entities instead of just putting Unicode characters in HTML? Let's say I want to put a non-bland character in an HTML file; for instance, '→'. Is there any reason why I should

@Karen161

Posted in: #Compatibility #ContentEncoding #Html #Unicode

Let's say I want to put a non-bland character in an HTML file; for instance, '→'. Is there any reason why I should enter it as '→' instead of just putting '→' in the HTML file? Assume my HTML file is encoded & transmitted in some Unicode format.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Karen161

2 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

Just to add to the excellent accepted answer: on the whole, ASCII files are much more portable across various editors.

10% popularity Vote Up Vote Down


 

@Murphy175

Those two final statements are big assumptions.

For example, we have a web app that uses AJAX to its literal meaning - we use it for loading XML documents on the fly. If the XML document does not have the correct content-encoding header (or is lacking one at all), then any unicode characters (smartquotes, long dashes, even some special whitespace and the word Café) makes Internet Explorer fall on its arse every single time. The AJAX request just fails and fires off a javascript error.

However, if we do a server-side replace of all the unicode characters with their HTML entities, everything works just fine.

Of course, if your file has the correct content-headers then this shouldn't be a problem for any modern browser.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme