List of XML and HTML character entity references


From Wikipedia, the free encyclopedia
  (Redirected from Character entity references)
Jump to navigationJump to search

In SGML, HTML and XML documents, the logical constructs known as character data and attribute values consist of sequences of characters, in which each character can manifest directly (representing itself), or can be represented by a series of characters called a character reference, of which there are two types: a numeric character reference and a character entity reference. This article lists the character entity references that are valid in HTML and XML documents.

A character entity reference refers to the content of a named entity. An entity declaration is created by using the <!ENTITY name "value"> syntax in a Document Type Definition (DTD).

Character reference overview

A numeric character reference refers to a character by its Universal Character Set/Unicode code point, and uses the format:

&#nnnn;

or

&#xhhhh;

where nnnn is the code point in decimal form, and hhhh is the code point in hexadecimal form. The x must be lowercase in XML documents. The nnnn or hhhh may be any number of digits and may include leading zeros. The hhhh may mix uppercase and lowercase, though uppercase is the usual style.

In contrast, a character entity reference refers to a character by the name of an entity which has the desired character as its replacement text. The entity must either be predefined (built into the markup language) or explicitly declared in a Document Type Definition (DTD). The format is the same as for any entity reference:

&name;

where name is the case-sensitive name of the entity. The semicolon is required, unless marked otherwise in the table below (see [a]).

Standard public entity sets for characters

ISO Entity Sets
SGML supplied a comprehensive set of entity declarations for characters widely used in Western technical and reference publishing, for Latin, Greek and Cyrillic scripts. The American Mathematical Society also contributed entities for mathematical characters.
HTML Entity Sets
Early versions of HTML built in small subsets of these, relating to characters found in three Western 8-bit fonts.
MathML Entity Sets
The W3C developed a set of entity declarations for MathML characters.
XML Entity Sets
The W3C MathML Working Group took over maintenance of the ISO public entity sets, combined with the MathML and documents them in XML Entity Definitions for Characters. This set can support the requirements of XHTML, MathML and as an input to future versions of HTML.
HTML 5
HTML5 adopts the XML entities as named character references, however it restates them without reference to their sources and does not group them into sets. The HTML 5 specification additionally provides mappings from the names to Unicode character sequences using JSON.

Numerous other entity sets have been developed for special requirements, and for major and minority scripts. However, the advent of Unicode has largely superseded them.

Predefined entities in XML

The XML specification does not use the term "character entity" or "character entity reference". The XML specification defines five "predefined entities" representing special characters, and requires that all XML processors honor them. The entities can be explicitly declared in a DTD, as well, but if this is done, the replacement text must be the same as the built-in definitions. XML also allows other named entities of any size to be defined on a per-document basis.

The table below lists the five XML predefined entities. The initial "Name" column mentions the entity's name. The "Character" column shows the character. To render the character, the format &name; is used; for example, &amp; renders as &. The "Unicode code point" column cites the character via standard UCS/Unicode "U+" notation, which shows the character's code point in hexadecimal. The decimal equivalent of the code point is then shown in parentheses. The "Standard" column indicates the first version of XML that includes the entity. The final "Name" column cites the character via its canonical UCS/Unicode name.

Character entity references in HTML

The HTML 5 DTDs define many named entities, references to which act as mnemonic aliases for certain Unicode characters.[1] The HTML 5 specification requires the use of the standard DTDs and does not allow users to define additional entities.

In the table below, the "Standard" column indicates the first version of the HTML DTD that defines the character entity reference. To use one of these character entity references in an HTML or XML document, enter an ampersand followed by the entity name and a semicolon, e.g., enter &copy; for the copyright symbol (©).

Alternatively, enter an ampersand, followed by a number sign, a number and a semicolon. For example, to display the copyright symbol ©, enter &#169; (When using this method, use the parenthesized decimal numbers in the third column.) Equivalently, you can enter an ampersand, followed by a number sign, the letter x, a hexadecimal number and a semicolon. For example, to display the copyright symbol © enter &#x00A9; or &#xA9;. (When using this method, use the hexadecimal numbers in the third column, without the prefix U+.)

Notes

  1. ^ 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 The trailing semicolon may be omitted for this named entity.
  2. ^ 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.
    or
    • original html.dtd refers to:
      • The original HTML 1.0 DTD, which would have been available at http://info.cern.ch/MarkUp/html-spec/html.dtd
  3. ^ Old ISO subset: these are old (documented) character subsets used in legacy encodings before the unification within ISO 10646.
  4. ^ 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.
  5. ^ a b c d spaces: a blue background is used to display each space's width.
  6. ^ angst: 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.
  7. ^ a b ijlig: The use of U+0132 and U+0133 'IJ ligature', which was encoded for usage in Dutch, and for compatibility for ISO/IEC 6937 and Code page 1102 (which only includes the lowercase ij; the Dutch version of ISO 646, National Replacement Character Set), is discouraged, and the preferred representation is simply IJ and ij (as two separate letters).
  8. ^ a b lmidot: The use of U+013F and U+0140 'L with middle dot', which was encoded for usage in Catalan, and for compatibility for ISO/IEC 6937, is discouraged, and the preferred representation is L/l followed by U+00B7.
  9. ^ napost: 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). The preferred representation is ʼn (U+02BC followed by n). (Unicode.org - Proposal for Additional Deprecated Characters).
  10. ^ a b ligature: this is a standard misnomer as this is a separate character in some languages.
  11. ^ ohm: 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.
  12. ^ a b c d e black: here it seems to mean filled as opposed to hollow.
  13. ^ a b ISO proposed: these characters have been standardized in ISO 10646 after the release of HTML 4.0.
  14. ^ alefsym: 'alef symbol' is not the same as U+05D0 'Hebrew letter alef', although the same glyph could be used to depict both characters.
  15. ^ beth: 'bet symbol' is not the same as U+05D1 'Hebrew letter bet', although the same glyph could be used to depict both characters.
  16. ^ gimel: 'gimel symbol' is not the same as U+05D2 'Hebrew letter gimel', although the same glyph could be used to depict both characters.
  17. ^ daleth: 'dalet symbol' is not the same as U+05D3 'Hebrew letter dalet', although the same glyph could be used to depict both characters.
  18. ^ lArr: 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.
  19. ^ rArr: ISO 10646 does not say that 'rightwards double arrow' is the 'implies' character but does not have another character with this function, so rArr can be used for 'implies' as ISOtech suggests.
  20. ^ prod: 'n-ary product' is not the same character as U+03A0 'Greek capital letter Pi' though the same glyph might be used for both.
  21. ^ sum: 'n-ary summation' is not the same character as U+03A3 'Greek capital letter Sigma' though the same glyph might be used for both.
  22. ^ sim: 'tilde operator' is not the same character as U+007E 'tilde', although the same glyph might be used to represent both.
  23. ^ nsup: note that nsup, 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, but was erroneously omitted from the entities list; it should be included for symmetry and analogy with other entities.
  24. ^ perp: Unicode only defines U+22A5 as the "up tack". 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.
  25. ^ sdot: U+22C5 'dot operator' is not the same character as U+00B7 'middle dot'.
  26. ^ U+22D8 does not have the lll entity in the HTML 5.2 list, but was erroneously omitted from the list.
  27. ^ lang: 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 has 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).
  28. ^ rang: 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).

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 &apos; entity) have the same names and represent the same characters as the 252 character entities in HTML. Also, by virtue of being XML, XHTML documents may reference the predefined &apos; entity, which is not one of the 252 character entities in HTML 4. 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:

  • If the document is read by a conforming HTML processor, then only the 252 HTML character entities can safely be used. The use of &apos; or custom entity references may not be supported and may produce unpredictable results.
  • 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 (see above) can safely be used, although other entities may be used if they are declared in the internal DTD subset.
  • If the document is read by an XML parser that does read external entities, then the five built-in XML character entities 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.

Because of the special &apos; case mentioned above, only &quot;, &amp;, &lt;, and &gt; will work in all processing situations.

See also

  • Character encodings in HTML
  • HTML decimal character rendering
  • SGML entity
  • Digraph and Trigraph (a similar concept to enter unavailable characters)

References

  1. ^ "HTML5 Named Character Reference List".

Further reading

  • Unicode Consortium. See also: Unicode Consortium
    • UnicodeData.txt from the Unicode Consortium
  • World Wide Web Consortium. See also: World Wide Web Consortium
    • XML 1.0 spec
    • HTML 2.0 spec
    • HTML 3.2 spec
    • HTML 4.0 spec
    • HTML 4.01 spec
    • HTML 5 spec
    • XHTML 1.0 spec
    • XML Entity Definitions for Characters
  • 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
  • W3 HTML5 Character Reference Chart

External links

  • Character entity references in HTML 4 at the W3C
  • Webpage for encoding and decoding special characters
Retrieved from "https://en.wikipedia.org/w/index.php?title=List_of_XML_and_HTML_character_entity_references&oldid=1064453128"