欧元符号 HTML
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1385835/
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
Euro sign in HTML
提问by caw
The euro () is the official currency in 22 European states.
欧元 () 是欧洲 22 个国家的官方货币。
In HTML there are different possibilities to display the sign :
在 HTML 中,显示标志有不同的可能性:
€
€
€
€
€
€
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.
你会在 HTML 中使用哪一个?我认为所有浏览器都不支持任何表示。遗憾的是没有标准的方式来显示标志。
Can you recommend one of the representations? What are the differences? Which ist supported best?
你能推荐其中一种代表吗?有什么区别?哪个支持最好?
I hope you can help me. Thank you very much in advance!
我希望你能帮助我。非常感谢您提前!
回答by Konrad Rudolph
Which one would you use in HTML?
你会在 HTML 中使用哪一个?
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.
他们都没有。使用适当的编码(即:UTF-8 或其他 Unicode 转换)并直接使用字符。如果可以避免,请不要使用 HTML 实体,因为与使用正确的编码相比,它们没有任何优势。
Also, this is wrong:
另外,这是错误的:
It's a pity that there is no standard way to display the sign.
遗憾的是没有标准的方式来显示标志。
There is, and it's the way I've described. Literally everybrowser, down to and including MSIE 5 will display Unicode characters correctly if the chosen fond supports the glyph.
有,这就是我描述的方式。如果所选的喜欢支持字形,实际上每个浏览器,包括 MSIE 5 都将正确显示 Unicode 字符。
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?
唯一的 有效的不使用 Unicode 字符而是退回到实体的原因可能是使用不支持 Unicode 的旧软件的项目。但这永远不应该发生,对吧?
回答by Josef Pfleger
According to Google Doctype€
is supported in all browsers. But maybe not all fonts.
根据Google Doctype€
,所有浏览器都支持。但也许不是所有字体。
editI also agree with Konrad Rudolph, use the character directly if you can.
编辑我也同意 Konrad Rudolph 的观点,如果可以的话直接使用这个角色。
回答by Wouter Dorgelo
From Google's HTML/CSS styleguide:
来自 Google 的 HTML/CSS 样式指南:
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.
不要使用实体引用。假设文件和编辑器以及团队之间使用相同的编码 (UTF-8),则无需使用 —、”或 ☺ 之类的实体引用。
The only exceptions apply to characters with special meaning in HTML (like < and &) as well as control or “invisible” characters (like no-break spaces).
唯一的例外适用于 HTML 中具有特殊含义的字符(如 < 和 &)以及控制或“不可见”字符(如不间断空格)。
<!-- Not recommended -->
The currency symbol for the Euro is “&eur;”.
<!-- Recommended -->
The currency symbol for the Euro is “”.
回答by paxdiablo
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).
您真的应该对其进行测试并将支持它的浏览器指定为最低要求。这大大减轻了您的工作量,因为它使用户负责:-) 或者,或者,使用单词“欧元”或“欧元”货币指示符(如美元、澳元、日元等)。
回答by Sergio Abreu
I use €
as you can see here : € it works in Firefox, Chrome and IE at least.
我使用€
你在这里看到的:€它至少适用于 Firefox、Chrome 和 IE。
回答by íhor Mé
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.
不是 Unicode,顺便说一句,即使它有效。是 ANSI。JavaScript String.fromCodePoint(128) 会给你一个你甚至看不到的控制字符。远离那个。
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.
如果您打算对符号使用纯 UTF-8 文本,您可能会在更改 db 属性后最终出错,或者如果您只是将其输入到文件中,一旦您不小心将其复制到 ANSI 编码中,或者某些使用其他编码的文件。到过那里。