[Javascript] Re: Charset (sort-of OFF_TOPIC for js)

Bill Moseley moseley at hank.org
Mon Aug 14 11:14:23 CDT 2006


On Mon, Aug 14, 2006 at 11:32:58AM -0400, tedd wrote:
> At 7:08 AM -0700 8/14/06, Bill Moseley wrote:
> >What should display for a byte with a value of 192?  You have to tell
> >the browser how to translate the string of bytes into characters --
> >and that's what the charset setting does.
> 
> Okay, assuming your value is HEX, the code point 0192 is Latin 
> Capital Letter A with grave.

How do you know that?  I didn't tell you want encoding table to use
to look up that value.

> UTF-8 will translate that easily enough, next code point? (Rhetorical 
> question)

If it's utf-8 then it would be an incomplete utf8 sequence.

> And, as I've asked before, does any of this affect javascript? Will
> having the wrong charset cause js to fail in some way?

Good question.  I think it depends on the browser's support.  IIRC,
Mozilla used to always assume 8859-1, but now I think it will also
look for a Byte Order Mark.

You can specify the charset of the javascript in the script element:

    http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.1

But, it's better to make sure the server sends the correct charset
when serving the file.

I serve everything as utf8, but there's nothing in my javascript that
isn's ascii.  It's rare that I have literal strings in my javascript.



-- 
Bill Moseley
moseley at hank.org




More information about the Javascript mailing list