|  | ECMAScript character set is UTF-16? |  | |
| | | optimistx |  |
| Posted: Thu Sep 04, 2008 4:33 pm Post subject: ECMAScript character set is UTF-16? |  |
Is it true that in order to follow standard, javascript code must be UTF-16? ECMA-262.pdf, chapter 6:
"ECMAScript source text is represented as a sequence of characters in the Unicode character encoding, version 2.1 or later, using the UTF-16 transformation format."
If so, should I send js-files from the server in that format instead of UTF-8, to be a standards obeying citizen? |
| |
| | | Joost Diepenmaat |  |
| Posted: Thu Sep 04, 2008 4:42 pm Post subject: Re: ECMAScript character set is UTF-16? |  |
| |  | |
"optimistx" <optimistxPoista@poistahotmail.com> writes:
| Quote: | Is it true that in order to follow standard, javascript code must be UTF-16? ECMA-262.pdf, chapter 6:
"ECMAScript source text is represented as a sequence of characters in the Unicode character encoding, version 2.1 or later, using the UTF-16 transformation format."
If so, should I send js-files from the server in that format instead of UTF-8, to be a standards obeying citizen?
|
Assuming you're talking about browser scripting, no you don't have to. Since javascript has no built-in methods of reading files or streams, all source text must be provided by the host (the browser, or whatever) in whatever encoding(s) the particular implementation accepts (which may or may not be UTF-16, but there isn't really any way to tell from JS code in an otherwise conformant implementation).
Since all decent browsers can deal with a multitude of text encodings, it's not needed to sent JS in UTF-16. You can also use ASCII, UTF8, Latin-1 and probably a bunch of other encodings - the browser should translate it if needed.
-- Joost Diepenmaat | blog: LINK | work: LINK |
| |
|
|