JavaScript: Source Code Encoding

By Xah Lee. Date: . Last updated: .

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:

Reference

js spec 2016 encoding RGcsC
ECMAScriptยฎ 2016 Language Specification#sec-ecmascript-language-source-code
BUY ฮฃJS JavaScript in Depth