SGML、HTML、XML文書 では、文字データおよび属性値と呼ばれる論理構造は文字のシーケンスで構成されます。各文字は直接表現することも(自身を表す)、文字参照と呼ばれる一連の文字で表現することもできます。文字参照には、数値文字参照と文字実体参照の2種類があります。この記事では、HTMLおよびXML文書で有効な文字実体参照を一覧表示します。
HTML および XML では、数値文字参照は、 Universal Coded Character Set / Unicodeコード ポイントによって文字を参照し、次の形式を使用します。&#xhhhh;または、XML 文書では小文字でなければなりません。&#nnn;は16 進形式のコードポイント、は10 進形式のコード ポイントです。(または) は任意の数の 16 進数 (または 10 進数) の数字で、先頭にゼロを含めることができます。16進数の数字には大文字と小文字を混在させることができますが、通常は大文字を使用します。XML および HTML 規格では、使用可能なコード ポイントを有効な値のセットに制限しています。これは UCS/Unicode コード ポイント値のサブセットであり、非文字またはサロゲートに割り当てられたすべてのコード ポイント、および C0 および C1 コントロールに割り当てられたほとんどのコード ポイント (空白として扱われる行区切り文字とタブを除く) を除外します。xhhhhnnnhhhhnnnhhhh
対照的に、文字実体参照は、目的の文字を置換テキストとして持つ実体の名前によって、1 つ以上の文字のシーケンスを参照します。形式は次のとおりです。ここで、は実体の大文字小文字を区別する名前です。セミコロンは、次の表で特に指定されていない限り、文字実体参照では通常必要です ( [ a ]を参照)。実体は、事前に定義されている (マークアップ言語に組み込まれている) か、またはを使用して文書型定義(DTD)で宣言されている必要があります。[ b ]&name;name<!ENTITY name "value">
&これらの5つのエンティティには、XML(およびXHTML )では末尾のセミコロンが必須です(HTMLやSGMLでは、DTDに従って一部のエンティティでセミコロンを省略できる場合もあります)。<>'"特別な要件や、主要な文字体系および少数派の文字体系に対応するために、他にも数多くのエンティティセットが開発されてきた。しかし、 Unicodeの登場により、それらはほぼ不要となった。
DTDエンティティサブセット(文字エンティティ名が定義されている部分)の完全な正式な公開識別子とシステム識別子は、実際には以下の3つの定義済み名前付きエンティティのいずれかからマッピングされます。
PUBLIC "-//W3C//ENTITIES HTML MathML Set//EN//XML" "http://www.w3.org/2003/entities/2007/htmlmathml-f.ent"ISOエンティティサブセットは、ISO 8879およびISO 9573でSGML文字エンティティ名が付けられている古い(文書化された)文字サブセットであり、ISO 10646による統合以前のレガシーエンコーディングで使用されていました。それらの正式な公開識別子は以下のとおりです。
HTML5 では、多くの名前付きエンティティが定義されており、それらへの参照は特定の Unicode 文字のニーモニック エイリアスとして機能します。[ 5 ] HTML5 仕様では、HTML ドキュメント内で参照または拡張される DTD がもはや受け入れられないため、ユーザーが追加のエンティティを定義することはできません (これは、より厳密な XML 解析ルールに基づいているが、ドキュメント ヘッダーで DTD を参照または定義できる XHTML ではまだ必要です。これは、XML がほとんどの HTML エンティティを事前に定義していないためです)。
以下の表の「Standard」列は、文字実体参照を定義する HTML DTD の最初のバージョンを示し、DTD を必要とせずに XML で事前定義されている文字を示します。これらの文字実体参照のいずれかを HTML または XML ドキュメントで使用するには、アンパサンド(&) の後に実体名、セミコロン(XML では必須、HTML ではすべての実体に対して強く推奨されますが、HTML では、以下に[ a ]で示す一部の実体からのみセミコロンを省略できます) を入力します。たとえば、©著作権記号©の場合はと入力します。
HTML には、UCS でエンコードされたほとんどのスクリプトの文字またはシーケンスに対応する事前定義された文字実体はありません (空白、句読点、数学記号または技術記号、通貨記号、数学表記で使用される少数のヘブライ語記号、およびラテン文字、ギリシャ文字、キリル文字の最も一般的な文字の一般的なサブセットを除く)。また、 UCS/Unicode で定義されているすべての双方向コントロールが HTML の標準文字実体として表現されるわけではないことにも注意してください (より一般的な方向性要素と属性を定義している HTML5 でも表現されません)。特に、UCS/Unicode で追加され、Unicode Bidi Algorithm バージョン 2 で正式に定義されたコントロールには、事前定義された HTML 文字実体はありません。
ほとんどのエンティティは、UCS の 1 つの文字だけを参照するように XML および HTML で事前定義されていますが、孤立した結合文字、バリエーションセレクタ、またはプライベート使用割り当て用の文字の事前定義エンティティはありません。ただし、リストには、それらのいくつかを含む 2 つの文字の文字シーケンスの事前定義エンティティが含まれています。HTML 5.0 (および同じエンティティセットを共有する MathML 3.0) 以降、すべてのエンティティは Unicode 正規化形式 C および KC でエンコードされています (これは、HTML および MathML の古いバージョンではそうではなかったため、プライベート使用割り当て用の文字、CJK 互換形式、または非 NFC 形式で最初に定義された古いエンティティは変更されました[ 6 ] )。
ただし、UCS のすべての有効な文字とシーケンス(双方向制御やプライベート使用割り当てを含む。ただし、空白文字以外の C0 および C1 制御、非文字、サロゲートを除く)は、HTML、XML、XHTML、MathML でも使用可能で有効です。属性のプレーンテキスト値として、またはテキスト要素として使用できます(プレーンテキストとして直接エンコードするか、必要に応じて数値文字参照を使用します)。
" was omitted from the HTML 3.2 specification, but was restored as of HTML 4.0. In practice, most web browsers displaying HTML 3.2 pages render it as if it had been included in the spec.©: 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.IJ and ij: 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).ŀ: 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).Ω: 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.​, ​, ​, ​: 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.ℑ, ↦: 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, so lArr can 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, so rArr can 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, lang was 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, rang had 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).The XHTMLDTDs 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:
' or custom entity references may not be supported and may produce unpredictable results (it is recommended to use the numerical character reference ' instead).Because of the special ' case mentioned above, only ", &, <, and > will work in all XHTML processing situations.