在HTML中显示unicode符号 [英] Displaying unicode symbols in HTML

查看:452
本文介绍了在HTML中显示unicode符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想简单地在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,请检查/请尝试以下操作:


  • 确保您的编辑器将其另存为UTF-8。或任何文件传输程序不会与文件混淆。 尝试使用HTML编码实体,如& #uuu;

  • 要确定,hexdump文件并且看起来像是字符,对于✔,它应该是E2 9C 94。注意:如果使用系统找不到字形的unicode字符(不带该字符的字体),那么您的浏览器应该显示一个问号或一些符号块。但是,如果您看到像您这样的多个罗马字符,则表示存在编码问题。


    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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆