JavaScript: Source Code Encoding
What is JavaScript's Charset?
JavaScript source code's charset is Unicode.
It means, JavaScript source code can contain any character of Unicode. For example, including any Chinese character, or Egyptian Hieroglyph, or emoji.
What is JavaScript's default encoding for source code?
JavaScript spec does not specify a default encoding for source code file. It depends on the encoding from HTTP protocol configured by the web server. [see HTTP Protocol Tutorial]
UTF-8 encoding is recommended. You should save JavaScript file in UTF-8 encoding. UTF-8 is the standard encoding for much of web technologies.
see:
- Set Text Editor File Encoding
- Unicode: Character Set, Encoding, UTF-8, Codepoint
- HTML: Charset and Encoding
Reference
