Html & 或 & 如果我们在 xhtml 文档中使用 utf8,&(&符号)应该使用什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2141799/
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
& or & what should be used for & (ampersand) if we are using utf8 in xhtml document?
提问by Jitendra Vyas
What is the difference between this &
and this &
for &(ampersand)? What should be use with utf8 ?
&(&) 的this&
和 this 有什么区别&
?utf8 应该使用什么?
回答by Gumbo
Both are character referencesand refer to the same character (AMPERSAND, U+0026). &
is a named or entity character reference and &
is a numerical character reference.
两者都是字符引用并引用相同的字符(AMPERSAND, U+0026 )。&
是命名或实体字符引用并且&
是数字字符引用。
In fact, &
is actually just a substitution for &
(see list of character entities):
事实上,&
实际上只是替代&
(参见字符实体列表):
<!ENTITY amp CDATA "&" -- ampersand, U+0026 ISOnum -->
<!ENTITY amp CDATA "&" -- ampersand, U+0026 ISOnum -->
回答by Joel Etherton
http://www.xml.com/pub/a/2001/01/31/qanda.html
http://www.xml.com/pub/a/2001/01/31/qanda.html
According to O'Reilly you should be using & in xml. UTF-8 is quite a bit different. http://www.fileformat.info/info/unicode/char/0026/index.htm
根据 O'Reilly,您应该在 xml 中使用 & 。UTF-8 有点不同。http://www.fileformat.info/info/unicode/char/0026/index.htm
回答by Kyle Butt
No difference. Utf-8 doesn't matter because & is reserved anyway. So use &
没有不同。utf-8 无关紧要,因为 & 无论如何都是保留的。所以使用 &