Html Chrome 不显示特殊字符,而其他浏览器显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21654259/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Chrome doesn't display special character while other browsers do
提问by Keavon
I am trying to display character code ❯
in a breadcrumb trail navigation which forms this arrow: ❯
我正在尝试❯
在形成此箭头的面包屑导航中显示字符代码:❯
It displays properly in Firefox, Opera, and IE but not in Chrome. Am I doing something wrong, or is this a bug in Chrome? Are there any workarounds?
它可以在 Firefox、Opera 和 IE 中正确显示,但不能在 Chrome 中正确显示。我做错了什么,还是 Chrome 中的错误?有什么解决方法吗?
I am using Google Chrome Version 32.0.1700.107 m on Windows 7 Professional 64 bit.
我在 Windows 7 Professional 64 位上使用 Google Chrome 版本 32.0.1700.107 m。
采纳答案by Jukka K. Korpela
This is almost a duplicate of Can't display character on IE 9, but since that question is specifically about IE and this one is about Chrome, I'll copy the answer, with modifications, here:
这几乎是Can't display character on IE 9的副本,但由于这个问题专门针对 IE 而这个问题是关于 Chrome 的,我将在此处复制答案并进行修改:
Browsers (including Chrome) sometimes have difficulties in rendering a character when it does not exist in the fonts specified for an element or, in the absence of such specifications, in the browser's default font. Browsers shouldcheck all the fonts in the system to find out one that contains the character, but sometimes they fail to do that. Sometimes the reason is that some font has information that claims that it has a glyph for the character (so the browser stops searching) but hasn't.
浏览器(包括 Chrome)有时在渲染某个字符时会遇到困难,因为它不存在于为元素指定的字体中,或者在没有此类规范的情况下,在浏览器的默认字体中。浏览器应该检查系统中的所有字体以找出包含该字符的字体,但有时他们无法做到这一点。有时原因是某些字体的信息声称它具有字符的字形(因此浏览器停止搜索)但没有。
The cure is to specify a list of fonts know to contain the character. For “?” U+276F HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT (a rather special character), font coverage is very limited. Most computers have no font containing it. You can specify a font list like the following:
解决方法是指定一个已知包含该字符的字体列表。为了 ”?” U+276F HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT(一个比较特殊的字符),字体覆盖非常有限。大多数计算机没有包含它的字体。您可以指定如下所示的字体列表:
font-family: DejaVu Sans, Symbola, Everson Mono, Dingbats, Segoe UI Symbol,
Quivira, SunExt-A, FreeSerif, Universalia, unifont;
But most users lack all of these fonts. You might consider using a downloadable font (web font) with @font-face. DejaVu fonts, Symbola, and Quivira are free fonts, though they are rather large in file size.
但大多数用户缺乏所有这些字体。您可以考虑使用带有@font-face 的可下载字体(网络字体)。DejaVu 字体、Symbola 和 Quivira 是免费字体,但它们的文件大小相当大。
Alternatively, consider using an image. This character is an ornamental dingbat, a special graphic rather than a character, though for legacy reasons it has been encoded as a character in Unicode.
或者,考虑使用图像。这个字符是一个装饰性的 dingbat,一个特殊的图形而不是一个字符,但由于遗留原因,它已被编码为 Unicode 中的一个字符。
More info: Guide to using special characters in HTML.
更多信息:在 HTML 中使用特殊字符的指南。
回答by Marcus Schack-Abildskov
Have you tried to use
你有没有试过使用
htmlspecialchars(string)
htmlspecialchars(string)
or
或者
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-8">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-8">
回答by geedew
[Edit] Apparently, it's a known problem for UTF-16, not UTF-8. [/EDIT]
[编辑] 显然,这是 UTF-16 的一个已知问题,而不是 UTF-8。[/编辑]
It's a known problem. The simplest fallback is to use a Unicode surrogate pair.
这是一个已知的问题。最简单的回退是使用 Unicode 代理对。
[sources]
[来源]
http://www.fileformat.info/info/unicode/char/10095/index.htm
http://www.fileformat.info/info/unicode/char/10095/index.htm