user893182
user893182

Reputation: 97

French character in JavaScript

I have a script.js file linking in the head of a HTML page (meta: utf-8)

French characters inside the HTML itself are displayed correctly, but those inside the script.js are not:

$('#count_fr').html("entrées") is displayed as entr[]es in browser.

Here is how I point to the js file:

<script type="text/javascript" src="script.js"></script>

I tried

<script type="text/javascript" src="script.js" charset="utf-8"></script>

but no luck.

Upvotes: 2

Views: 12029

Answers (3)

user3297888
user3297888

Reputation: 21

I also tried to use Unicode directly for French characters in Javascript files. It works perfectly for me. e.g. \u00fb for û.

Here is the link for Unicode list (please see the Basic Latin list): http://en.wikipedia.org/wiki/List_of_Unicode_characters

Upvotes: 2

abahgat
abahgat

Reputation: 13530

It looks like the script file is not saved as UTF-8. You can verify it by using the file command on UNIX like systems, or by opening your text editor and looking for a menu command to change the encoding.

Upvotes: 4

Adilson de Almeida Jr
Adilson de Almeida Jr

Reputation: 2755

Open the js file in a text editor and check the encoding.

Upvotes: 0

Related Questions