Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I "UTF-8 encode" my JavaScript files so that Google Chrome can use them in an extension?

I am writing a fairly simple extension for Chrome. The main graphical body of it (the part dealing with html, i.e. the front-end) works fine, but when I try to include a second JavaScript file that uses Jquery's $.ajax() function to return some info from another page to the front-end, Chrome throws the following error and won't let me load the extension:

Could not load extension from "Path\to\extension". Could not load file "filename.js" for content script. It isn't UTF-8 encoded.

I don't honestly know enough about UTF-8 encoding to be able to tell what would make Chrome say that about my file. I have no special characters, no accent marks or anything, which i know can screw things up. I haven't been able to find a good solution anywhere, either.

like image 760
Ken Bellows Avatar asked Mar 08 '11 19:03

Ken Bellows


People also ask

Does Google use UTF-8?

Bookmark this question. Show activity on this post. Apparently Google's encoding is UTF-8 as it's stated in it's html meta tag.

How do I change my browser encoding to UTF-8?

Select "View" from the top of your browser window. Select "Text Encoding." Select "Unicode (UTF-8)" from the dropdown menu.

Does JavaScript use UTF-8?

In other words, the character encoding translates the Unicode code points to unique code unit sequences. Popular encodings are UTF-8, UTF-16 and UTF-32. Most JavaScript engines use UTF-16 encoding, so let's detail into UTF-16.


1 Answers

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

like image 176
Ekkehard.Horner Avatar answered Sep 22 '22 17:09

Ekkehard.Horner