& or & what should be used for & (ampersand) if we are using utf8 in xhtml document?

前端 未结 4 700
暗喜
暗喜 2021-01-01 12:08

What is the difference between this & and this & for &(ampersand)? What should be use with utf8 ?

相关标签:
4条回答
  • 2021-01-01 12:42

    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

    0 讨论(0)
  • 2021-01-01 12:49

    Both are character references and refer to the same character (AMPERSAND, U+0026). & is a named or entity character reference and & is a numerical character reference.

    In fact, & is actually just a substitution for & (see list of character entities):

    <!ENTITY amp     CDATA "&#38;"   -- ampersand, U+0026 ISOnum -->
    
    0 讨论(0)
  • 2021-01-01 12:53

    No difference. Utf-8 doesn't matter because & is reserved anyway. So use &amp;

    0 讨论(0)
  • 2021-01-01 12:57

    If you both save your file in UTF-8 and even specify it for strict browsers:

    <head><meta charset="utf-8">
    

    I would guess that you can also just use the & character. All new browsers will support it and UTF-8.

    0 讨论(0)
提交回复
热议问题