How to "encode UTF-8" my JavaScript files so that Google Chrome can use them in the extension?

I am writing a fairly simple extension for Chrome. The main graphic body (the part related to html, i.e. the Interface) works fine, but when I try to include a second JavaScript file that uses the JQuery $ .ajax () function to return some information from another page to the front-end, Chrome gives the following error and will not allow me to download the extension:

Failed to load extension from "Path \ to \ extension". Failed to load file "filename.js" for script contents. It is not UTF-8 encoded.

I honestly don't know enough about UTF-8 encoding to be able to tell what Chrome would say about my file. I have no special characters, no accent marks or anything else that I know can hurt. I also could not find a good solution.

+3
source share
3 answers

An easy way to encode UTF-8 files is to use an editor that allows you to select this encoding. If you cannot do this, there are (fairly standard) tools on the linux / unix system to check (file) and change (iconv, transcode) the encoding. If you use Windows, such tools can be installed.

+4
source
0

I ran into this problem, although the file was saved by UTF-8. However, the code contained a character U+FFFFthat was invalid by definition . The same for U+FFFE.

The solution was "\uffff"to use a symbol instead of directly using it.

0
source

All Articles