ECMAScript character set is UTF-16?

O

optimistx

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?
 
J

Joost Diepenmaat

optimistx said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top