热门问题
时间线
聊天
视角
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