最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

utf 8 - UTF-8 and Javascript - Stack Overflow

programmeradmin9浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 13

The encoding of the files must be set to UTF8.

发布评论

评论列表(0)

  1. 暂无评论