I\'m building a website with the encoding UTF-16. It means that every files (html,jsp) is encoded in UTF-18 and I set in the head of every HTML page :
(Disclosure: I’m the developer responsible for the relevant code in Firefox.)
I'm building a website with the encoding UTF-16.
Please don’t. The short rules are:
If you include user-provided content on your pages, using UTF-16 means that your site is vulnerable to socially engineered XSS at least in older browsers. Try this demo in an old version of Firefox (version 20 or older) or in a Presto-based version of Opera.
To avoid the vulnerability, use UTF-8.
It means that every files (html,jsp) is encoded in UTF-18
Uh oh. :-)
and I set in the head of every HTML page :
<meta http-equiv="content-type" content="text/html; charset=UTF-16">
A meta tag works as an internal encoding declaration only when the encoding being used maps the bytes of the meta tag to the same bytes ASCII would. That’s not the case for UTF-16.
Do you know the reason?
Not without full response headers and the original response body in a hex editor. The general solution, as noted above, is to use always UTF-8 and never to use UTF-16 over HTTP.
If your content is in a language for which UTF-16 is more compact than UTF-8, two things:
Check that the server sends a Content-Type
header with the correct encoding.