From: Thomas 'PointedEars' Lahn on
Jukka K. Korpela wrote:

> The encoding of Javascript files is tricky issue. There are no defined
> defaults

Yes, there are.

> On general grounds, we can expect that browsers honor the encoding
> information in HTTP headers.

Correct.

> However, if the Javascript resource is served as application/javascript,
> then it's supposed to be binary, with all encoding issues resolved within
> the binary format.

Rubbish.

> There's RFC 4329, "Scripting media types", but it is classified as
> Informational, despite its language that refers to "requirements" and even
> uses "MUST". And it illogically defines a charset parameter for
> application/javascript. Oh well.

Perhaps you can explain what is wrong with the `charset' parameter for
application/javascript?

> For text/javascript, declared as "obsolete" by the informational RFC,

Yes, one wonders if the author of that RFC has ever written a cross-browser
script.

> the charset parameter is much more logical.

No, it isn't.

> And it seems that browsers honorit.

They honor it with application/javascript as well, iff they support the
media type at all.

> On the practical side, if you work with a typical Apache server
> environment, you should put e.g.
> AddType text/javascript;charset=utf-8 js
> or
> AddType application/javascript;charset=utf-8 js
>
> in the .htaccess file in the directory that contains your .js file, if
> they are actually utf-8 encoded. [...]

The proper directives in that case are

AddType text/javascript;charset=utf-8 .js

and

AddType application/javascript;charset=utf-8 .js

respectively. See
<http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addtype>


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
From: Hans-Georg Michna on
On Mon, 5 Jul 2010 09:33:59 +0100, Richard Cornford wrote:

>Hans-Georg Michna wrote:

>> Here's an intermediate information, the response header issued
>> by the server when it delivers the JavaScript file:
>>
>> Response Headers view source
>> Date Mon, 05 Jul 2010 07:43:32 GMT
>> Server IBM_HTTP_Server/6.1.0.19 Apache/2.0.47 (Unix)
>> Last-Modified Mon, 14 Jun 2010 12:34:48 GMT
>> Content-Length 2676
>> Keep-Alive timeout=10, max=99
>> Connection Keep-Alive
>> Content-Type application/x-javascript
>> Content-Language de-DE

>Didn't you just tell me that "I've looked at the HTTP header from the
>server, using Firebug, and it specifies UTF-8"? If these are the headers
>where is that specification of UTF-8?

Oops, and, of course, that test server is now down, so I cannot
recheck.

But please see my later posting.

Hans-Georg
From: Jukka K. Korpela on
Hans-Georg Michna wrote:

> I've looked at the HTTP header from the server, using Firebug,
> and it specifies UTF-8.

If you just posted the URL, others could check whether the server actually
specifies UTF-8 and what the referenced resource actually contains. My
current bet is that everything is OK except that your file is not in fact
UTF-8 encoded. Such problems have become more common (though usually with
HTML files) in the recent years when overenthusiastic web server
administrators have specified that HTTP headers shall contain charset=utf-8
and innocent web authors have used whatever they have been using.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

From: Hans-Georg Michna on
By the way, I couldn't give out the URL, because the stuff is on
an intranet, not publicly visible.

Hans-Georg
First  |  Prev  | 
Pages: 1 2 3 4
Prev: Sound-synched movie
Next: Energy Saving Tips