Typically, I use utf-8
for everything. Is utf-8
acceptable for JavaScript
header('Content-Type: application/javascript; charset=utf-8');
Reason I ask is http://kunststube.net/encoding/ states:
What does it mean for a language to support Unicode then? Javascript for example supports Unicode. In fact, any string in Javascript is UTF-16 encoded. In fact, it's the only thing Javascript deals with. You cannot have a string in Javascript that is not UTF-16 encoded. Javascript worships Unicode to the extent that there's no facility to deal with any other encoding in the core language. Since Javascript is most often run in a browser that's not a problem, since the browser can handle the mundane logistics of encoding and decoding input and output.
Should I be using utf-16
instead of utf-8
? Or does this article pertain to how JavaScript encodes text, not how the browser deencodes the text of a file which happens to be JavaScript?