简体   繁体   English

HTML Unicode问题:如何显示特殊字符

[英]HTML Unicode Issue: How to display special characters

Currently, I have my webpage set to Unicode/UTF-8. 目前,我的网页设置为Unicode / UTF-8。 When trying to display a special character (for example, em dash, double arrow, etc), it shows up as a question mark symbol. 当试图显示特殊字符(例如,短划线,双箭头等)时,它会显示为问号符号。 I cannot change these characters to the HTML entity equivalent. 我无法将这些字符更改为等效的HTML实体。 How can I circumvent this issue? 我该如何规避这个问题?

A question mark in a lozenge, , indicates a character-level error: the data contains bytes that do no represent any character, according to the character encoding being applied. 菱形中的问号 表示字符级错误:根据所应用的字符编码,数据包含不代表任何字符的字节。 This typically happens when the document is declared as UTF-8 encoded but is really in iso-8859-1, windows-1252, or some similar encoding. 这通常发生在文档被声明为UTF-8编码时,但实际上是在iso-8859-1,windows-1252或类似的编码中。 Windows-1252 is a common default encoding used by various programs on Windows platforms. Windows-1252是Windows平台上各种程序使用的常见默认编码。 So you may need to open the file in your authoring program and re-save it as UTF-8 encoded. 因此,您可能需要在创作程序中打开该文件并将其重新保存为UTF-8编码。

If problems remain, please post the URL. 如果问题仍然存在,请发布网址。 Posting the code alone is not sufficient, since the character encoding is primarily specified in HTTP headers. 单独发布代码是不够的,因为字符编码主要在HTTP头中指定。

If you see a question mark in a small box, then it might be a font-level problem (lack of glyph in the fonts being used), but this would be very rare for common characters like the em dash. 如果你在一个小方框中看到一个问号,那么它可能是一个字体级问题(正在使用的字体中缺少字形),但对于像em破折号这样的常见字符来说这是非常罕见的。 Different browsers have different ways of indicating character- or font-level problems. 不同的浏览器有不同的方式来指示字符或字体级别的问题。

Make sure your document is set to the correct character encoding in the actual code editor, as well as in the doctype. 确保在实际代码编辑器和doctype中将文档设置为正确的字符编码。 Both are necessary. 两者都是必要的。 I spent hours trying to tweak HTML when the only problem was that I needed to set the text setting in Coda. 当我唯一的问题是我需要在Coda中设置文本设置时,我花了几个小时试图调整HTML。

<head>
    <meta charset="utf-8">

See the following screenshot: 请参阅以下屏幕截图:

在此输入图像描述

Make sure your characters are actually UTF-8 characters. 确保您的角色实际上是UTF-8字符。 They will probably look something like this: 他们可能看起来像这样:

&#174; or U+0020

http://www.kinsmancreative.com/transfer/char/index.php is a handy site for finding the decimal values of commonly used UTF-8 special characters if you need a reference. http://www.kinsmancreative.com/transfer/char/index.php是一个方便的网站,用于查找常用UTF-8特殊字符的十进制值,如果您需要参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM