热门问题
时间线
聊天
视角
XML与HTML字符实体引用列表
维基媒体列表条目 来自维基百科,自由的百科全书
Remove ads
在SGML、 HTML与XML文档,如果某些Unicode字符在文档的当前编码方式(如ISO-8859-1)中不能直接表示,那么可以通过字符值引用或者字符实体引用两种转义序列来表示这些不能直接编码的字符。 下文列出在HTML与XML文档中有效的字符实体引用。
XML中的预定义实体
XML规范并不使用“字符实体”(character entity)或“字符实体引用”(character entity reference)。 XML规范定义了5个“预定义实体”来表示特殊字符。 XML也允许在每个文档定义任意数量的其它命名实体。
下表列出了5个XML预定义实体。 通过名字引用这些实体的格式为&name;
,例如&
将绘制为 &。
Remove ads
HTML中的字符实体引用
HTML 4 DTD定义了252个命名实体。HTML 4规范要求使用标准DTD,并且不许用户定义其它的命名实体。
下表中,“标准”栏指出该字符实体首次定义在哪个版本的HTML DTD中。HTML 4.01没有增加任何新的字符实体。
Notes:
- DTD: the full public DTD name (where the character entity name is defined) is actually mapped from one of the following three defined named entities:
- HTMLlat1 maps to:
- PUBLIC "-//W3C//ENTITIES Latin 1//EN//HTML" in HTML (the DTD is implicitly defined, no system URI is needed);
- PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent" in XHTML 1.0;
- HTMLsymbol maps to:
- PUBLIC "-//W3C//ENTITIES Symbols//EN//HTML" in HTML (the DTD is implicitly defined, no system URI is needed);
- PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent" in XHTML 1.0;
- HTMLspecial maps to:
- PUBLIC "-//W3C//ENTITIES Special//EN//HTML" in HTML (the DTD is implicitly defined, no system URI is needed);
- PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent" in XHTML 1.0.
- HTMLlat1 maps to:
- Old ISO subset: these are old (documented) character subsets used in legacy encodings before the unification within ISO 10646.
- 描述: ISO 10646与Unicode字符名称写在前面,其它常用同义项写在后面
- 空间: 蓝色背景表示空格的宽度.
- ligature: this is a standard misnomer as this is a separate character in some languages.
- ISO proposed: these characters have been standardized in ISO 10646 after the release of HTML 4.0.
- alefsym: 阿列夫符号并不等同于U+05D0 '希伯来字母阿列夫', 虽然二字字形几乎相同.
- lArr: 根据ISO 10646,向左双线箭头还可用于'is implied by'(由...推导出)箭头.
- rArr: 根据ISO 10646,向左双线箭头还可用于'implies'(推导出)箭头.
- prod: '连乘符号'不同于U+03A0 '希腊大写字母Pi',虽然二者字形几乎相同.
- sum: '求和符号'不同于U+03A3 '希腊大写字母Sigma',虽然二者字形几乎相同.
- sup: 注意到nsup, U+2283 'not a superset of'(不是...的超集), 并没有被包含进HTML字符实体引用之中. 看起来不够对称,不够完美吧? 它在ISOamsn子集中.
- perp: Unicode定义了U+22A5作为"up tack"(向上的大头钉), 以及U+27C2作为"perpendicular" (垂直符号). 这两个符号看起来几乎是一样的,但它们是不同的Unicode字符. 但是, HTML使用U+22A5作为"perpendicular"(垂直符号). 这就在HTML与Unicode之间产生了矛盾.
- sdot: 'dot operator'(点算符)不同于U+00B7 'middle dot'(中点符号).
- lang: 'left-pointing angle bracket'不同于这些字符:U+003C 'less than', U+2039 'single left-pointing angle quotation mark', U+2329 'left-pointing angle bracket', U+27E8 'mathematical left angle bracket', or U+3008 'left angle bracket' ,虽然这些字符看起来都差不多.
- rang: 'right-pointing angle bracket'不同于这些字符:U+003E 'greater than', U+203A 'single right-pointing angle quotation mark', U+232A 'right-pointing angle bracket', U+27E9 'mathematical right angle bracket', or U+3009 'right angle bracket' ,虽然这些字符看起来都差不多.
- black: here it seems to mean filled as opposed to hollow.
Remove ads
XHTML中的特殊字符的实体引用
在XHTML DTD中,明确声明了253个字符实体(包括5个XML 1.0的预定义实体)。 除了'
实体这个例外,其它252个字符实体与HTML中的252个字符实体引用一致。每个XHTML文件实例还可以定义任意数目的字符实体。但是XHTML字符实体的可用性受到该文件的处理方式的影响:
- 如果该文件由HTML处理器来处理, 那么只有252个 HTML字符实体可用。
'
或用户定义的实体引用可能不被支持,产生不可预测的效果. - 如果该文件由XML分析器来处理,只有5个XML预定义的字符实体能安全使用,虽然定义在内部DTD子集中的其它实体也许可用。
- 如果XML分析器能读外部实体,那么除了5个XML预定义的字符实体能安全使用,只要XML分析器能读取XHTML DTD,其它248个HTML字符实体也可以使用。声明在内部DTD子集中的实体也可以使用.
由于'
不能在HTML处理器中一致的安全使用,实际上仅有"
, &
, <
, and >
4个字符实体可以在所有处理环境下通用。
参见
参考文献
- Unicode Consortium (页面存档备份,存于互联网档案馆). See also: Unicode Consortium
- World Wide Web Consortium (页面存档备份,存于互联网档案馆). See also: World Wide Web Consortium
- The normative reference to RFC 2070 (still found in DTDs defining the character entities for HTML or XHTML) is historic; this RFC (along with other RFC's related to different part of the HTML specification) has been deprecated in favor of the newer informational RFC 2854 which defines the "text/html" MIME type and references directly the W3C specifications for the actual HTML content.
- Numerical Reference of Unicode code points at Wikibooks
Remove ads
外部链接
- Character entity references in HTML 4 (页面存档备份,存于互联网档案馆) at the W3C
- Multilanguage special character entity list (页面存档备份,存于互联网档案馆) - List of special characters, entities and their names.
- HTML entities quick reference table
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads