I use Javascript to get data in a HTML pages define with a charset UTF8
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
my javascript method is load with a charset UTF8
<script type="text/javascript" charset="utf-8" src="../ressources/js/test.js"></script>
but i have a encode problem, when i get data with "innerHTML"
ex: salari�s
is there something I missed ?
I use Javascript to get data in a HTML pages define with a charset UTF8
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
my javascript method is load with a charset UTF8
<script type="text/javascript" charset="utf-8" src="../ressources/js/test.js"></script>
but i have a encode problem, when i get data with "innerHTML"
ex: salari�s
is there something I missed ?
Share Improve this question asked Jul 22, 2011 at 13:20 halna frédérichalna frédéric 2382 gold badges3 silver badges11 bronze badges 4- 3 How are you getting the data? Where are you getting it from? What are you doing to it before you display it? Do you have a (real) HTTP header that say a different content-type is being used? Have you checked that you have actually saved the data using UTF-8 and you aren't just slapping a UTF-8 label on a document that is actually ISO-8859-1, Windows 1252 or something else? – Quentin Commented Jul 22, 2011 at 13:22
- The fact that your code claims that the HTML and JS data is encoded in UTF-8 doesn't mean that it is. Have you checked, e.g. with file (linux.die.net/man/1/file) or some hexadecimal editor? – Pierre Thierry Commented Jul 22, 2011 at 13:25
- for example: i have an Article with a heading and a "read more" link. I use a innertHtml on the heading and put the string in the "read more" title. it's correctly display in the heading, not in the title. – halna frédéric Commented Jul 22, 2011 at 13:29
- i check: my js and html file are encoded in UTF-8 – halna frédéric Commented Jul 22, 2011 at 13:34
1 Answer
Reset to default 13The encoding of the files must be set to UTF8.