# 符号的 HTML 字符实体是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3025171/
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
What's the HTML character entity for the # sign?
提问by chimerical
What's the HTML character entity for the # sign? I've looked around for "pound" (keeps returning the currency), and "hash" and "number", but what I try doesn't seem to turn into the right character.
# 符号的 HTML 字符实体是什么?我四处寻找“英镑”(不断返回货币)、“哈希”和“数字”,但我尝试的似乎没有变成正确的字符。
回答by BalusC
You can search it on the individual character at fileformat.info. Enter #
as search string and the 1st hit will lead you to U+0023. Scroll a bit down to the 2nd table, Encodings, you'll see under each the following entries:
您可以在fileformat.info的单个字符上搜索它。输入#
作为搜索字符串,第一次点击将引导您到U+0023。向下滚动到第二个表Encodings,您将在每个表下看到以下条目:
HTML Entity (decimal) # HTML Entity (hex) #
回答by acdcjunior
For #
we have #
.
因为#
我们有#
.
Bear in mind, though, it is a new entity (IE9 can't recognize it, for instance). For wide support, you'll have to resort, as said by others, the numerical references #
and, in hex, #
.
但请记住,它是一个新实体(例如,IE9 无法识别它)。为了获得广泛的支持,您将不得不求助于其他人所说的数字参考#
和十六进制的#
.
If you need to find out others, there are some very useful toolsaround.
如果您需要了解其他人,这里有一些非常有用的工具。
回答by David Cary
The "#" -- like most Unicode characters -- has no particular name assigned to it in the W3 list of "Character entity references" http://www.w3.org/TR/html4/sgml/entities.html. So in HTML it is either represented by itself as "#" or a numeric character entity "#" or "#" (without quotes), as described in "HTML Document Representation" http://www.w3.org/TR/html4/charset.html.
“#”——与大多数 Unicode 字符一样——在“字符实体引用”的 W3 列表中没有分配特定的名称 http://www.w3.org/TR/html4/sgml/entities.html。因此,在 HTML 中,它要么由自身表示为“#”,要么表示为数字字符实体“#” 或“#” (不带引号),如“HTML 文档表示” http://www.w3.org/TR/html4/charset.html 中所述。
Alas, all three of these are useless for escaping it in a URL. To transmit a "#" character to the web server in a URL, you want to use "URL encoding" aka "percent encoding" as described in RFC 3986, and replace each "#" with a "%23" (without quotes).
唉,所有这三个对于在 URL 中转义它都是无用的。要将“#”字符传输到 URL 中的 Web 服务器,您需要使用“URL 编码”,即 RFC 3986 中所述的“百分比编码”,并将每个“#”替换为“%23”(不带引号) .
回答by Guffa
There is no HTML character entity for the #
character, as the character has no special meaning in HTML.
字符没有 HTML 字符实体#
,因为字符在 HTML 中没有特殊含义。
You have to use a character code entity like #
if you wish to HTML encode it for some reason.
您必须使用字符代码实体,就像#
您出于某种原因希望对它进行 HTML 编码一样。
回答by whatsisname
# or #
http://www.asciitable.com/has information. Wikipedia also has pages for most unicode characters.
http://www.asciitable.com/有信息。维基百科也有大多数 unicode 字符的页面。
回答by Matthew Flaschen
The numerical reference is #
.
参考数字是#
。
回答by Matthew Flaschen
# is the best option because it is the only one that doesn't include the # (hash) in it. Supported by old browsers or not, it is the best practice going forward.
# 是最好的选择,因为它是唯一不包含 #(哈希)的选项。无论旧浏览器是否支持,这是未来的最佳实践。
(What is the point of encoding something using the same symbol you are encoding?)
(使用您正在编码的相同符号对某些内容进行编码有什么意义?)