在HTML中显示unicode符号 [英] Displaying unicode symbols in HTML
问题描述
我想简单地在HTML页面中显示tick(✔)和cross(✘)符号,但它显示为盒子或goopâ显然是与编码有关的。
我已经设置meta标签来显示utf-8,但显然我错过了一些东西。
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
编辑/解决方案:使用FireBug发表的评论,被我的页面传递的实际上是Content-Type:text / html而不是UTF-8。使用Notepad ++查看文件格式显示我的文件被格式化为没有BOM的UTF-8。把它改为UTF-8,符号现在可以正确显示......但是firebug仍然显示出相同的content-type。 解决方案
p>您应该确保HTTP服务器标头是正确的。
特别是,标题:
Content-Type:text / html; charset = utf-8
应该存在。
此外,请确保您的文件在提供之前实际被编码为UTF-8,请检查/请尝试以下操作:
& #uuu;
。
I want to simply display the tick (✔) and cross (✘) symbols in a HTML page but it shows up as either a box or goop âœ" - obviously something to do with the encoding.
I have set the meta tag to show utf-8 but obviously I'm missing something.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Edit/Solution: From comments made, using FireBug I found the headers being passed by my page were in fact "Content-Type: text/html" and not UTF-8. Looking at the file format using Notepad++ showed my file was formatted as "UTF-8 without BOM". Changing this to just UTF-8 the symbols now show correctly... but firebug still seems to indicate the same content-type.
You should ensure the HTTP server headers are correct.
In particular, the header:
Content-Type: text/html; charset=utf-8
should be present.
The meta tag is ignored by browsers if the HTTP header is present.
Also ensure that your file is actually encoded as UTF-8 before serving it, check/try the following:
- Ensure your editor save it as UTF-8.
- Ensure your FTP or any file transfer program does not mess with the file.
- Try with HTML encoded entities, like
&#uuu;
. - To be really sure, hexdump the file and look as the character, for the ✔, it should be E2 9C 94 .
Note: If you use an unicode character for which your system can't find a glyph (no font with that character), your browser should display a question mark or some block like symbol. But if you see multiple roman characters like you do, this denotes an encoding problem.
这篇关于在HTML中显示unicode符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!