Recent Entries:

Favorite Links

Encoding of included JSON files

Tuesday, October 7th, 2008

Lately I had a problem with a page which was including two JSON scripts, one encoded in UTF-8 and the other encoded in ISO-8859-1.

In some circumstances (and in some browsers) the strings where not showed correctly.
Hunting down the problem required a good dose of my favourite tool wget -S where the -S option causes the http response headers to be printed on stderr.

My conclusions are that:

In other words, to make a script inclusion cross-browser and independent of the encoding of the page you are including the script, always use the following if your page is using iso-8859-1

or

if your page is utf-8.

And of corse, make sure your http headers match the content!

Leave a Reply