欧元符号 HTML
欧元 (€) 是 22 个欧洲国家的官方货币。
在 HTML 中,有不同的可能性显示 € 符号:
€
€
€
哪一个会你在 HTML 中使用吗?我认为所有浏览器都不支持任何表示形式。遗憾的是,没有标准的方式来显示标志。
您能推荐其中一种代表吗?有什么区别?哪个支持最好?
The euro (€) is the official currency in 22 European states.
In HTML there are different possibilities to display the sign €:
€
€
€
Which one would you use in HTML? I think no representation is supported in all browsers. It's a pity that there is no standard way to display the sign.
Can you recommend one of the representations? What are the differences? Which ist supported best?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
没有一个。使用适当的编码(即:UTF-8 或其他 Unicode 转换)并直接使用字符。如果可以避免的话,请不要使用 HTML 实体,因为与使用正确的编码相比,它们没有任何优势。
另外,这是错误的:
是有的,而且就是我所描述的方式。从字面上看,如果所选的字体支持字形,则每个浏览器(低至 MSIE 5)都将正确显示 Unicode 字符。
不使用 Unicode 字符而是回退到实体的唯一
有效原因可能是使用不能很好支持 Unicode 的旧版软件的项目。但这永远不应该发生,对吧?None of them. Use an appropriate encoding (i.e.: UTF-8 or another Unicode transform) and use the charcter directly. Do not use HTML entities if at all avoidable, since they’ve got no advantage over use of a proper encoding.
Also, this is wrong:
There is, and it’s the way I’ve described. Literally every browser, down to and including MSIE 5 will display Unicode characters correctly if the chosen fond supports the glyph.
The only
validreason to not use Unicode characters and instead fall back to entities might be projects that use legacy software which doesn’t support Unicode well. But that should never happen, right?根据 Google Doctype
€
支持在所有浏览器中。但也许不是所有字体。编辑
我也同意康拉德·鲁道夫的观点,如果可以的话,直接使用这个角色。
According to Google Doctype
€
is supported in all browsers. But maybe not all fonts.edit
I also agree with Konrad Rudolph, use the character directly if you can.
来自 Google 的 HTML/CSS 样式指南:
不要使用实体引用。
假设文件和编辑器以及团队之间使用相同的编码 (UTF-8),则无需使用诸如 —、” 或 ☺ 之类的实体引用。
唯一的例外适用于 HTML 中具有特殊含义的字符(例如 < 和 &)以及控制或“不可见”字符(例如不间断空格)。
From Google's HTML/CSS styleguide:
Do not use entity references.
There is no need to use entity references like —, ”, or ☺, assuming the same encoding (UTF-8) is used for files and editors as well as among teams.
The only exceptions apply to characters with special meaning in HTML (like < and &) as well as control or “invisible” characters (like no-break spaces).
您实际上应该测试它并指定支持它的浏览器作为最低要求。这大大减轻了您的工作量,因为它使用户负责:-) 或者,也可以使用单词“欧元”或“欧元”货币指示符(如美元、澳元、日元等)。
You should really just test it and specify those browsers that support it as minimum requirements. This eases your workload considerably since it makes the user responsible :-) Or, alternatively, use the word "euro" or the "EUR" curruncy designator (like USD, AUD, JPY and so on).
我使用
€
,正如您在此处看到的: € 它至少适用于 Firefox、Chrome 和 IE。I use
€
as you can see here : € it works in Firefox, Chrome and IE at least.接受的答案实际上很糟糕,至少到目前为止是这样。 最好的选择是使用 €
€顺便说一句,尽管它可以工作,但它不是 Unicode。是ANSI。 JavaScript String.fromCodePoint(128) 将为您提供一个您甚至看不到的控制字符。远离那个。
如果您要使用纯 UTF-8 文本作为符号,则在更改数据库属性后,或者如果您只是将其输入到文件中,一旦您不小心将其复制到 ANSI 编码或某些文件中,您可能最终会遇到错误。使用其他一些编码的文件。去过那里。
The accepted answer is actually awful,at least as of today. Best choice is to use €
€ is not Unicode, btw, even though it works. It's ANSI. JavaScript String.fromCodePoint(128) will give you a control character you won't even be able to see. Stay away from that.
If you're going to use plain UTF-8 text for symbols you might end up having mistakes after changing db properties, or if you're just typing it into file, once you accidentally copy it into an ANSI-coded, or some a file with some other encoding. Been there.