Reputation: 137
I used Chrome.i18n and wrote several message.json files. And I didn't know which file format should choose for it. ANSI, UTF-8 or others. And I find most of the chrome extensions chosed ANSI. Is it the standard format for message.json file?
Upvotes: 2
Views: 579
Reputation: 32102
Your file has to be saved as UTF-8 for non-ASCII characters (accented letters, Chinese characters, etc.) to work. The "ANSI" setting may work if no such characters exist in any of the messages. Do not select UTF-16.
Text editors often guess character encodings of text files by looking for characteristic patterns of byte values. It is not possible to distinguish Windows-1252 or other so-called "ANSI" encodings from UTF-8 in the absence of non-ASCII characters because ASCII is a common subset of both. Your text editor apparently assumes "ANSI", indicating UTF-8 only when non-ASCII characters are actually in use in the Chrome extensions you have seen.
Some text editors (Windows Notepad in particular) add a byte order mark (BOM) to any file saved as UTF-8. Although that character allows determining the file's UTF-8 encoding, Google Chrome does not expect to see it and fails to load the JSON file.
If you use Windows Notepad, you ought to switch to Notepad++ or another text editor that has an option to save as "UTF-8 without BOM". You also should consider setting up your editor to use UTF-8 by default, even for existing files.
Upvotes: 3