admin管理员组文章数量:1327553
I have a webpage on which I'm using a unicode down triangle on buttons to indicate that selecting those buttons will display a drop-down.
I'm adding the triangles in css thusly:
.icon:after {
content:"▼";
}
.icon {
width:12px;
height:12px;
margin: 3px;
display: inline-block;
cursor:default;
}
The meta tags in the page are:
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; chrome=1" >
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
However, the triangles don't show up as triangles, they show up like this:
Any idea why it might be showing up like this and how to fix it?
I have a webpage on which I'm using a unicode down triangle on buttons to indicate that selecting those buttons will display a drop-down.
I'm adding the triangles in css thusly:
.icon:after {
content:"▼";
}
.icon {
width:12px;
height:12px;
margin: 3px;
display: inline-block;
cursor:default;
}
The meta tags in the page are:
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; chrome=1" >
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
However, the triangles don't show up as triangles, they show up like this:
Any idea why it might be showing up like this and how to fix it?
Share Improve this question edited Nov 7, 2017 at 0:13 elemjay19 asked Oct 16, 2012 at 0:27 elemjay19elemjay19 1,1664 gold badges26 silver badges52 bronze badges 6-
This is clearly a file encoding issue. You can avoid it by just using
content:"\25bc";
– Raymond Chen Commented Oct 16, 2012 at 0:30 - @RaymondChen is that supported across all browsers? – elemjay19 Commented Oct 16, 2012 at 0:31
- I'll leave you to research that. You have to do some of the work, too. – Raymond Chen Commented Oct 16, 2012 at 0:32
- @RaymondChen alternatively, you could put that in an answer, with an explanation, and then I could accept it if it works – elemjay19 Commented Oct 16, 2012 at 0:34
-
Here is a nice site for Useful UTF-8 Characters with
CSS Escape
and also read this article. – The Alpha Commented Oct 16, 2012 at 1:10
2 Answers
Reset to default 6You can shape all kind of chars using any kind of unicode character. In your case for example you just have to use something like:
.icon:after {
content:"\25bc";
}
or for a small triangle:
.icon:after {
content:"\25be";
}
This trick it's fully cross browser patible.
The document (HTML or CSS document) in which the CSS rule appears is sent with HTTP headers that specify an encoding other than UTF-8, probably ISO-8859-1 or windows-1252, or, in the case of a CSS document, do not specify the encoding at all, making browsers guess.
The solution is to fix this by changing the HTTP headers. See the W3C page Character encodings.
If HTTP headers do not specify the encoding, then charset declarations inside the document itself may take effect.
Using character escapes may help to remove the symptoms, but to avoid future problems (when someone adds an odd character into a document), it is best to get the encoding problem fixed.
本文标签: javascriptUnicode characterdown triangleshows up as strange textStack Overflow
版权声明:本文标题:javascript - Unicode character, down triangle, shows up as strange text - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742171248a2426752.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论