SGML、HTML、およびXML文書 では、文字データおよび属性値と呼ばれる論理構造は文字のシーケンスで構成されます。文字のシーケンスでは、各文字が直接表現される (それ自体を表す) か、文字参照と呼ばれる一連の文字によって表されます。文字参照には、数値文字参照と文字実体参照の 2 種類があります。この記事では、HTML および XML 文書で有効な文字実体参照の一覧を示します。
文字エンティティ参照は、名前付きエンティティのコンテンツを参照します。エンティティ宣言は、ドキュメント型定義(DTD)
<!ENTITY name "value">の構文を使用して、XML、SGML、および HTML ドキュメント (HTML5 以前) で作成されます。
キャラクターリファレンスの概要
HTML および XML では、数値文字参照はユニバーサル文字セット/ Unicode コード ポイントによって文字を参照し、次の形式を使用します。
&#xhhhh;
または
&#nnnn;
ここで、 はxXML 文書では小文字でなければなりません。hhhhは16 進形式のコード ポイント、nnnn は10 進形式のコード ポイントです。 hhhh (またはnnnn ) は任意の数の 16 進数 (または 10 進数) で、先頭にゼロを含めることができます。 16 進数のhhhhでは大文字と小文字を混在させることができますが、通常は大文字を使用します。 ただし、XML および HTML 標準では、使用可能なコード ポイントが有効な値のセットに制限されています。これは UCS/Unicode コード ポイント値のサブセットであり、非文字またはサロゲートに割り当てられたすべてのコード ポイント、および C0 および C1 制御に割り当てられたほとんどのコード ポイント (空白として扱われる行区切り文字とタブを除く) を除外します。
対照的に、文字実体参照は、置換テキストとして目的の文字を持つ実体の名前で、1つ以上の文字のシーケンスを参照します。実体は、事前に定義されているか(マークアップ言語に組み込まれているか)、または文書型定義(DTD)で明示的に宣言されている必要があります([a]を参照)。形式は、他の実体参照と同じです。
&name;
ここで、nameは実体の大文字と小文字を区別した名前です。以下の表で特に明記されていない限り、文字実体参照では通常セミコロンが必要です([b]を参照)。
文字の標準パブリックエンティティセット
- テキスト
- XML では、印刷可能なすべての ASCII 文字をサポートするために必要な 5 つの定義済みエンティティ (、、、、、) が指定されています。XML
&(および<XHTML ) では、これらの 5 つのエンティティの末尾のセミコロンは必須です (HTML または SGML では、DTD に従って、一部のエンティティの末尾のセミコロンを省略できる場合でも)。>'" - ISO エンティティ セット
- SGMLは、西洋の技術および参考文献の出版で広く使用されているラテン文字、ギリシャ文字、キリル文字の文字のエンティティ宣言の包括的なセットを提供しました。アメリカ数学会も数学文字のエンティティを提供しました( [c]を参照)。
- HTML エンティティ セット
- HTMLの初期バージョンでは、3 つの西洋 8 ビット フォントに含まれる文字に関連するこれらの小さなサブセットが組み込まれていました。
- MathML エンティティ セット
- W3Cは、MathML文字のエンティティ宣言のセットを開発しました。
- XML エンティティ セット
- W3C MathML ワーキング グループは、ISO パブリック エンティティ セットのメンテナンスを引き継ぎ、MathML と組み合わせて、文字の XML エンティティ定義に文書化しました。このセットは、XHTML、MathML の要件をサポートし、HTMLの将来のバージョンへの入力として使用できます。
- HTML5
- HTML5 はXML エンティティを名前付き文字参照として採用していますが、ソースを参照せずにそれらを再述し、セットにグループ化していません。HTML5 仕様では、 JSON を使用して名前から Unicode 文字シーケンスへのマッピングも提供しています。
特別な要件や主要および少数のスクリプト用に、他の多数のエンティティ セットが開発されてきました。しかし、Unicodeの登場により、それらのほとんどが置き換えられました。
HTML DTD エンティティ サブセットの正式な公開識別子
DTD エンティティ サブセット (文字エンティティ名が定義されている場所) の 完全な正式な公開識別子とシステム識別子は、実際には次の 3 つの定義済み名前付きエンティティのいずれかからマップされます。
- ^ オリジナルの HTML 1.0 DTD は http://info.cern.ch/MarkUp/html-spec/html.dtd で入手可能です。
- ^ HTML 5 にはすべてのエンティティがあらかじめ定義されている DTD はありません。カスタム XSD (少なくともカスタム "data-*" 属性) も定義せずに、(X)HTML 5 に必要なスキーマを XML で厳密に検証することは不可能です。DTD のサポート ( billion aughsなどの関連するセキュリティ上の懸念) を要求するのではなく、HTML5 と XHTML を安全に交換する最善の方法は、すべてのエンティティ参照をプレーンテキスト、数値文字参照、または (該当する場合) XML 1.0 の 5 つの標準エンティティに変換することです。そうは言っても、
- HTML 5エンティティセットはMathML 3でも使用されており、その目的のために、そのDTDエンティティサブセットには識別子セットが割り当てられています。[1]
PUBLIC "-//W3C//ENTITIES HTML MathML Set//EN//XML" "http://www.w3.org/2003/entities/2007/htmlmathml-f.ent" - WHATWG仕様では、ブラウザがMathML 2またはXHTML 1.x(XMLで使用される場合)の正式な公開識別子をHTML5エンティティセットを含むデータURIにマッピングし、提供されたシステム識別子よりも優先させることを推奨しています。これにより、「ネットワークアクセスを必要とせずに相互運用可能な方法でエンティティを処理」できるようになります。[2]
- HTML 5エンティティセットはMathML 3でも使用されており、その目的のために、そのDTDエンティティサブセットには識別子セットが割り当てられています。[1]
古い ISO エンティティ サブセットの正式な公開識別子
ISO エンティティ サブセットは、ISO 8879および ISO 9573 で SGML 文字エンティティ名が付けられ、ISO 10646 内で統合される前の従来のエンコードで使用されていた古い (文書化された) 文字サブセットです。完全な正式な公開識別子は次のとおりです。
- ^ abcdefghijklmnopqrsの 代わりに で始まるバージョンは非推奨とみなされます。[3]
ISO 8879-1986//ISO 8879:1986// - ^ 追加されたバージョンは
//HTML、より大きなHTMLlat1エンティティセットに対して誤って使用されることがあります。つまり、"-//W3C//ENTITIES Latin 1//EN//HTML"[3]の代わりに使用されます(上記参照)。
HTML の文字実体参照のリスト
HTML5では多くの名前付きエンティティが定義されており、それらへの参照は特定のUnicode文字のニーモニックエイリアスとして機能します。[5] HTML5仕様では、HTML文書内で参照または拡張されるDTDを受け入れなくなったため、ユーザーが追加のエンティティを定義することはできません(これは、より厳格なXML解析ルールに基づくXHTMLではまだ必要ですが、XMLではほとんどのHTMLエンティティが事前定義されていないため、ドキュメントヘッダーでDTDを参照または定義できます)。
以下の表の「標準」列は、文字エンティティ参照を定義する HTML DTD の最初のバージョンを示し、 は DTD を必要とせずに XML で事前定義されている文字を示します。HTML または XML ドキュメントでこれらの文字エンティティ参照のいずれかを使用するには、アンパサンド( &) に続けてエンティティ名とセミコロン(XML では必須、HTML ではすべてのエンティティに対して強く推奨) を入力します。ただし、HTML では、以下の[b]で示す一部のエンティティでのみセミコロンを省略できます。たとえば、©著作権記号©の場合は を入力します。
UCS でエンコードされたほとんどのスクリプトの文字またはシーケンスについては、HTML に定義済みの文字エンティティはありません (ただし、空白、句読点、数学または技術記号、通貨記号、数学表記法で使用されるいくつかのヘブライ文字、およびラテン文字、ギリシャ文字、キリル文字の最も一般的な文字の共通サブセットは除きます)。また、 UCS/Unicode で定義されている双方向コントロールのすべてがHTML の標準文字エンティティとして表されるわけではないことに注意してください (その目的でより一般的な方向要素と属性を定義している HTML5 でも表されません)。特に、UCS/Unicode で追加され、Unicode Bidi アルゴリズムのバージョン 2 で正式に定義されたコントロールについては、HTML に定義済みの文字エンティティはありません。
XML および HTML では、ほとんどのエンティティが UCS 内の 1 つの文字だけを参照するように定義済みですが、独立した結合文字、異体セレクタ、または私的使用割り当ての文字に対する定義済みエンティティはありません。ただし、リストには、それらのいくつかを含む 2 つの文字の文字シーケンスに対する定義済みエンティティがいくつか含まれています。HTML 5.0 (および同じ en エンティティのセットを共有する MathML 3.0) 以降、すべてのエンティティは Unicode 正規化形式 C および KC でエンコードされます (これは HTML および MathML の古いバージョンには当てはまらなかったため、私的使用割り当ての文字、CJK 互換形式、または非 NFC 形式で最初に定義された古いエンティティは変更されました[6] )。
ただし、UCS 内のすべての有効な文字とシーケンス (すべての双方向制御または私的使用の割り当てを含む (ただし、空白以外の C0 および C1 制御、非文字、およびサロゲートを除く)) は、属性のプレーン テキスト値またはテキスト要素 (プレーン テキストとして直接エンコードするか、必要に応じて数値文字参照を使用する) のいずれかで、HTML、XML、XHTML、および MathML でも使用可能かつ有効です。
Notes
- ^ a b DTD: see § Formal public identifiers for HTML DTD entities subsets
- ^ a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az ba bb bc bd be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv bw bx by bz ca cb cc cd ce cf cg ch ci cj ck cl cm cn co cp cq cr cs ct cu cv cw cx cy cz da db dc dd The trailing semicolon may be omitted for this named entity.
- ^ a b Old ISO subset: see § Formal public identifiers for old ISO entities subsets
- ^ Description: the standard ISO 10646 and Unicode character name is displayed first for each character, with non-standard but legacy synonyms shown in italics between parentheses after an equal sign.
- ^ a b c The leading space before combining characters used in old DTDs for MathML2.0 was removed in MathML 3.0 and HTML 5.0.
- ^
"was omitted from the HTML 3.2 specification,[1] but was restored as of HTML 4.0.[2] In practice, most web browsers displaying HTML 3.2 pages render it as if it had been included in the spec. - ^ a b c d spaces: a blue background is used to display each space's width.
- ^
©: U+00A9 'copyright symbol' is not the same as U+24B8 'circled Latin capital letter C', although the same glyph could be used do depict both characters. See also U+24D2 'Latin small letter c'. - ^
®: U+00AE 'registered sign' is not the same as U+24C7 'circled Latin capital letter R', although the same glyph could be used do depict both characters. - ^
Å: The use of U+212B 'Angstrom sign', which was encoded due to round-trip mapping compatibility with an East-Asian character encoding, is discouraged, and the preferred representation is U+00C5 'capital letter A with ring above', which has the same glyph. - ^ a b
IJandij: The use of U+0132 'IJ ligature' or U+0133 'ij ligature', which were encoded for usage in Dutch and for compatibility for ISO/IEC 6937 and Code page 1102 (which only includes the lowercase ij, also part of the Dutch version of ISO 646 National Replacement Character Set), is discouraged, and the preferred representation is simply 'IJ' or 'ij' (as two separate letters). - ^ a b
ŀ: The use of U+013F 'Latin small letter l with middle dot' or U+0140 'Latin capital letter L with middle dot', which were encoded for usage in Catalan and for compatibility for ISO/IEC 6937, is discouraged, and the preferred representation is 'L' or 'l', followed by U+00B7. - ^
ʼn: The use of U+0149 'n preceded by apostrophe', which was encoded for usage in Afrikaans and for compatibility for ISO/IEC 6937, has been deprecated by Unicode (since Unicode 5.2), and the preferred representation is ʼn (U+02BC followed by n). (Unicode.org – Proposal for Additional Deprecated Characters). - ^ a b ligature: this is a standard misnomer as this is a separate character in some languages.
- ^ a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw Greek letters: the ISOgrk1 set includes a set of entity names for the entire Greek alphabet (without diacritics),[7] while the ISOgrk3 set includes a different set of entity names for the subset of the Greek letters used contrastively with Latin letters in mathematical notation.[8] The HTML HTMLsymbol set includes an expanded version of the ISOgrk3 set, not the ISOgrk1 set.
- ^
Ω: The use of U+2126 'ohm sign', is discouraged, and the preferred representation is U+03A9 'Greek capital letter Omega', which has the same glyph. - ^ a b c d
​,​,​,​: these are names used in the Wolfram Language for Private Use Area characters with negative advance widths;[9][10][11][12] HTML5 approximates them with the zero-width space. - ^ a b c d e black: here it seems to mean filled as opposed to hollow.
- ^ a b ISO proposed: these characters have been standardized in ISO 10646 after the release of HTML 4.0.
- ^ a b c d
ℑ,↦: these two entity names were defined differently, as file-type icons, in the abandoned specification for HTML version 3.0.[13][14] - ^
℗: U+2117 'sound recording copyright' is not the same as U+24C5 'circled Latin capital letter P', although the same glyph could be used do depict both characters. - ^
ℵ: U+2135 'alef symbol' is not the same as U+05D0 'Hebrew letter alef' (which, unlike the mathematical symbol, has strong right-to-left bidirectional text behaviour), although the same glyph could be used to depict both characters. - ^
ℶ: U+2136 'bet symbol' is not the same as U+05D1 'Hebrew letter bet' (which, unlike the mathematical symbol, has strong right-to-left bidirectional text behaviour), although the same glyph could be used to depict both characters. - ^
ℷ: U+2137 'gimel symbol' is not the same as U+05D2 'Hebrew letter gimel' (which, unlike the mathematical symbol, has strong right-to-left bidirectional text behaviour), although the same glyph could be used to depict both characters. - ^
ℸ: U+2138 'dalet symbol' is not the same as U+05D3 'Hebrew letter dalet' (which, unlike the mathematical symbol, has strong right-to-left bidirectional text behaviour), although the same glyph could be used to depict both characters. - ^
⇐: ISO 10646 does not say that 'leftwards double arrow' is the same as the 'is implied by' arrow, but also does not have any other character for that function, solArrcan be used for 'is implied by' as ISOtech suggests. - ^
⇒: ISO 10646 does not say that 'rightwards double arrow' is the same as the 'implies' arrow, but also does not have any other character with this function, sorArrcan be used for 'implies' as ISOtech suggests. - ^
∏: U+220F 'n-ary product' is not the same character as U+03A0 'Greek capital letter Pi' though the same glyph might be used for both. - ^
∑: U+2211 'n-ary summation' is not the same character as U+03A3 'Greek capital letter Sigma' though the same glyph might be used for both. - ^
∼: U+223C 'tilde operator' is not the same character as U+007E 'tilde', although the same glyph might be used to represent both. - ^
⊅: U+2285 'not a superset of' is in the 'ISOamsn' subset, but is not covered by the Symbol font encoding, and is not listed in the HTML 4.0 entities list on the documentation, where it was erroneously omitted; it should be included for symmetry and analogy with other entities. - ^
⊥: Unicode only defines U+22A5 as the "up tack", and the Unicode symbol for "perpendicular" is U+27C2: the two symbols look similar, but are separate in Unicode. However, HTML uses U+22A5 as its "perpendicular" symbol: this is a discrepancy between HTML and Unicode. As well, the U+22A4 character (the "down tack" symbol) rendered in a browser such as Firefox 3.6 can match the font of either "up tack" or "perpendicular", but not both, depending on whether a fixed-width or a proportional font is used. When viewed in Firefox 3.6, the symbols rendered in the order U+22A5, U+22A4, U+27C2 in a proportional font: "⊥ ⊤ ⟂" and a fixed width one:⊥ ⊤ ⟂, shows that the "down tack" has a similar look to U+22A5 (HTML's "perpendicular") in the first case but matches U+27C2 in the second. This exemplifies the difficulties of the semiotics involved in interpreting glyphs, symbols and characters generally. - ^
⋅: U+22C5 'dot operator' is not the same character as U+00B7 'middle dot'. - ^
⋘: U+22D8 'very much less-than' is missing in the HTML 5.2 list of entities, where it was omitted. - ^
⟨: U+27E8 'mathematical left angle bracket' is not the same character as U+003C 'less than', U+2039 'single left-pointing angle quotation mark', or U+3008 'left angle bracket'. In HTML 5.0,langwas remapped to this code, as U+2329 'left-pointing angle bracket' has been marked deprecated in Unicode (since version 5.2) (Unicode.org – Proposal for Additional Deprecated Characters). - ^
⟩: U+27E9 'mathematical right angle bracket' is not the same character as U+003E 'greater than', U+203A 'single right-pointing angle quotation mark', or U+3009 'right angle bracket'. In HTML 5.0,ranghad been remapped to this code, as U+232A 'right-pointing angle bracket' has been marked deprecated in Unicode (since version 5.2) (Unicode.org – Proposal for Additional Deprecated Characters).
Entities representing special characters in XHTML
The XHTML DTDs explicitly declare 253 entities (including the 5 predefined entities of XML 1.0) whose expansion is a single character, which can therefore be informally referred to as "character entities". These (with the exception of the ' entity) have the same names and represent the same characters as the 252 character entities in HTML 4.0. Also, by virtue of being XML, XHTML documents may reference the predefined ' entity, which is not one of the 252 character entities in HTML 4.0. Additional entities of any size may be defined on a per-document basis. However, the usability of entity references in XHTML is affected by how the document is being processed:[citation needed]
- Legacy abbreviated character entities (without the final colon) inherited from HTML 2.0 (and still supported in HTML 5.0) are not supported in XML 1.0 and XHTML; the trailing semicolon must be present in all entity references used in XML and XHTML documents.
- If the XHTML document is read by a conforming HTML 4.0 processor, then only the 252 HTML 4.0 character entities may safely be used. The use of
'or custom entity references may not be supported and may produce unpredictable results (it is recommended to use the numerical character reference'instead). - If the document is read by an XML parser that does not or cannot read external entities, then only the five built-in XML character entities can safely be used, although other entities may be used if they are declared in the internal DTD subset. However, modern XML parsers recognize and implement a builtin cache for SGML references to DTDs used by all standard versions of HTML, XHTML, SVG and MathML, without needing to parse and process the external DTD via their URL and without needing to process entities defined in an internal DTD subset of the document.
- If the document is read by an XML parser that does read external entities and does not implement a builtin cache for well-known DTDs, then the five built-in XML character entities (and numeric character references) can safely be used. The other 248 HTML character entities can be used as long as the XHTML DTD is accessible to the parser at the time the document is read. Other entities may also be used if they are declared in the internal DTD subset and the XML processor can parse internal DTD subsets.[citation needed]
- HTML 5.0 parsers cannot process XHTML documents, and it's impossible to define a fully validating DTD for HTML5 documents encoded with the XHTML syntax (notably it's impossible to validate all attributes names, notably "data-*" attributes); as well it's still impossible to fully validate (with W3C standard schemas for XML, such as XSD or relax NG) HTML5 documents represented in the XHTML syntax, and for now a custom validator specific to HTML 5.0 is required.
Because of the special ' case mentioned above, only ", &, <, and > will work in all XHTML processing situations.
See also
- Character encodings in HTML
- Digraph and Trigraph, a similar concept to enter unavailable characters
- Escape character
- HTML decimal character rendering
- Percent-encoding, used in URLs
- SGML entity
References
- ^ "htmlmathml-f entity set". W3C. 2011.
- ^ "14.2 Parsing XML documents". HTML Standard. WHATWG. Retrieved 13 July 2024.
- ^ a b c d e f g h i j k l m n o p q r s t u "sgml-iso-entities-8879.1986/catalog". Debian. 2013.
- ^ a b c d e f g h i j k l m "sgml-iso-entities-9573-13.1991/catalog". Debian. 2013.
- ^ "HTML5 Named Character Reference List".
- ^ "XML Entity Definitions for Characters (3rd Edition) - § C Differences between these entities and earlier W3C DTDs".
- ^ 構造化情報標準推進機構 (OASIS) (2002)。「ISO ギリシャ文字エンティティ V0.3」。Debian。
- ^ 構造化情報標準推進機構 (OASIS) (2002)。「ISO ギリシャ語シンボルエンティティ V0.3」。Debian。
- ^ Wolfram . "\[NegativeThickSpace]". Wolfram言語ドキュメント。
- ^ Wolfram . "\[NegativeMediumSpace]". Wolfram言語ドキュメント。
- ^ Wolfram . "\[NegativeThinSpace]". Wolfram言語ドキュメント。
- ^ Wolfram . "\[NegativeVeryThinSpace]". Wolfram言語ドキュメント。
- ^ Hannah, Michael J. (1995 年 12 月 7 日). 「HTML アイコン: 提案された HTML アイコン エンティティ名」。2015 年 2 月 2 日時点のオリジナルよりアーカイブ。
- ^ 「標準 ISO/WWW アイコンは Bert Bos と Kevin Hughes の提供によるものです」。W3C。
さらに読む
- Unicode コンソーシアム。参照: Unicode コンソーシアム
- Unicode コンソーシアムの UnicodeData.txt
- ワールド ワイド ウェブ コンソーシアム。参照:ワールド ワイド ウェブ コンソーシアム
- XML 1.0 仕様
- HTML 2.0 仕様
- HTML 3.2 仕様
- HTML 4.0 仕様
- HTML 4.01 仕様
- HTML 5 仕様
- XHTML 1.0 仕様
- 文字の XML エンティティ定義
- RFC 2070 への規範的な参照 (HTML または XHTML の文字エンティティを定義する DTD にまだ含まれています) は歴史的なものです。この RFC (および HTML 仕様のさまざまな部分に関連する他の RFC) は、"text/html" MIME タイプを定義し、実際の HTML コンテンツの W3C 仕様を直接参照する新しい情報 RFC 2854 に置き換えられ、廃止されました。
- Wikibooks の Unicode コード ポイントの数値リファレンス
- W3 HTML5 文字参照表
外部リンク
- W3C の HTML 4 における文字実体参照
- 特殊文字のエンコードとデコードに関するウェブページ 2018年1月29日アーカイブ、Wayback Machine
