W3C home > Mailing lists > Public > www-international@w3.org > July to September 2007

http charset, <script> and IE

From: tex <tex@yahoo-inc.com>
Date: Sun, 29 Jul 2007 14:33:36 -0700
To: <www-international@w3.org>
Message-ID: <003301c7d228$2045d240$0500a8c0@ds.corp.yahoo.com>
I have been testing IE 7 and I find that if an html page calls an external javascript file, the browser doesn't seem to respect the charset setting in the http protocol.
If I set the charset in the script element <script charset=... src=...>
the script is loaded and converted to the character encoding of the web page.
However, if instead, I set charset in the http protocol that returns the .js file and do not use the charset attribute in the script element, IE7 doesn't perform a conversion.
Firefox works as I expect.
I have tried using several different mime types (text/javascript, application/javascript, application/x-javascript) and even different encoding names, since IE is a bit odd with Korean encoding names.
However, I can't seem to get IE7 to render a utf-8 html page properly that includes an euc-kr javascript file without setting the charset attribute in the script element.
For a number of reasons, I would prefer the web server set the encoding of the script rather than have the web page know how the script was authored. (Duh!)
Anyone found a way to get IE respect the http charset?
I did find that having the web page in the Korean encoding and including a utf-8 javascript file seemed to work, but I suspect it was because notepad put a bom on the file and IE used that rather than the http setting to deteremine the encoding and convert it to cp949.
I am hoping there is some quirk mode or non-quirk mode or new-quirk mode or captain-quirk mode that makes IE behave right.
I haven't tried IE 6 but I am guessing it has the same issue.
<rant on>
The concept of declaring encodings in the retrieving page rather than the retrieved page is brain-dead if you ask me and should be stricken from specs.
Authors and Pubishers should declare the encoding. (And it should be unicode.)
Consumers shouldn't have to figure out the encoding of material they consume.
</rant on>
Received on Sunday, 29 July 2007 21:33:55 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:40:54 UTC