Content deleted Content added
→References: Delete gibberish |
m convert special characters found by Wikipedia:Typo Team/moss (via WP:JWB) |
||
(29 intermediate revisions by 22 users not shown) | |||
Line 1:
{{Short description|Common markup construct used in SGML, XML, and HTML}}
{{one source|date=February 2021}}
A '''numeric character reference''' ('''NCR''') is a common [[markup (computer programming)|markup]] construct used in [[SGML]] and SGML-derived markup languages such as [[HTML]] and [[XML]]. It consists of a short sequence of [[character (computing)|character]]s that, in turn, represents a single character. Since [[SGML|WebSgml]], [[XML]] and [[HTML 4]], the code points of the [[Universal Character Set]] (UCS) of [[Unicode]] are used. NCRs are typically used in order to represent characters that are not [[plain text#Encoding|directly encodable]] in a particular document (for example, because they are international characters that
==Examples==
In SGML, HTML, and XML, the following are all valid numeric character references for the Greek capital letter Sigma
{| class="wikitable
|+ Numerical character reference of {{unichar|03A3|GREEK CAPITAL LETTER SIGMA}}<br/>({{hexadecimal|0931}} =
|-
! [[Unicode#Upluslink|Unicode character]]
Line 24 ⟶ 25:
In SGML, HTML, and XML, the following are all valid numeric character references for the Latin capital letter AE
{| class="wikitable
|+ Numerical character reference of {{unichar|00C6|Latin capital letter AE}}
|-
Line 38 ⟶ 39:
In SGML, HTML, and XML, the following are all valid numeric character references for the Latin small letter sharp s ß
{| class="wikitable
|+ Numerical character reference of {{unichar|00DF|Latin small letter sharp s}}
|-
Line 58 ⟶ 59:
! Effect
|-
| U+0020 || &#32; || &#x20; ||
|-
| U+0021 || &#33; || &#x21; ||
|-
| U+0022 || &#34; || &#x22; ||
|-
| U+0023 || &#35; || &#x23; ||
|-
| U+0024 || &#36; || &#x24; ||
|-
| U+0025 || &#37; || &#x25; ||
|-
| U+0026 || &#38; || &#x26; || &
|-
| U+0027 || &#39; || &#x27; ||
|-
| U+0028 || &#40; || &#x28; ||
|-
| U+0029 || &#41; || &#x29; ||
|-
| U+002A || &#42; || &#x2A; ||
|-
| U+002B || &#43; || &#x2B; ||
|-
| U+002C || &#44; || &#x2C; ||
|-
| U+002D || &#45; || &#x2D; ||
|-
| U+002E || &#46; || &#x2E; ||
|-
| U+002F || &#47; || &#x2F; ||
|-
| U+0030 || &#48; || &#x30; ||
|-
| U+0031 || &#49; || &#x31; ||
|-
| U+0032 || &#50; || &#x32; ||
|-
| U+0033 || &#51; || &#x33; ||
|-
| U+0034 || &#52; || &#x34; ||
|-
| U+0035 || &#53; || &#x35; ||
|-
| U+0036 || &#54; || &#x36; ||
|-
| U+0037 || &#55; || &#x37; ||
|-
| U+0038 || &#56; || &#x38; ||
|-
| U+0039 || &#57; || &#x39; ||
|-
| U+003A || &#58; || &#x3A; ||
|-
| U+003B || &#59; || &#x3B; ||
|-
| U+003C || &#60; || &#x3C; ||
|-
| U+003D || &#61; || &#x3D; ||
|-
| U+003E || &#62; || &#x3E; ||
|-
| U+003F || &#63; || &#x3F; ||
|-
| U+0040 || &#64; || &#x40; ||
|-
| U+0041 || &#65; || &#x41; ||
|-
| U+0042 || &#66; || &#x42; ||
|-
| U+0043 || &#67; || &#x43; ||
|-
| U+0044 || &#68; || &#x44; ||
|-
| U+0045 || &#69; || &#x45; ||
|-
| U+0046 || &#70; || &#x46; ||
|-
| U+0047 || &#71; || &#x47; ||
|-
| U+0048 || &#72; || &#x48; ||
|-
| U+0049 || &#73; || &#x49; ||
|-
| U+004A || &#74; || &#x4A; ||
|-
| U+004B || &#75; || &#x4B; ||
|-
| U+004C || &#76; || &#x4C; ||
|-
| U+004D || &#77; || &#x4D; ||
|-
| U+004E || &#78; || &#x4E; ||
|-
| U+004F || &#79; || &#x4F; ||
|-
| U+0050 || &#80; || &#x50; ||
|-
| U+0051 || &#81; || &#x51; ||
|-
| U+0052 || &#82; || &#x52; ||
|-
| U+0053 || &#83; || &#x53; ||
|-
| U+0054 || &#84; || &#x54; ||
|-
| U+0055 || &#85; || &#x55; ||
|-
| U+0056 || &#86; || &#x56; ||
|-
| U+0057 || &#87; || &#x57; ||
|-
| U+0058 || &#88; || &#x58; ||
|-
| U+0059 || &#89; || &#x59; ||
|-
| U+005A || &#90; || &#x5A; ||
|-
| U+005B || &#91; || &#x5B; ||
|-
| U+005C || &#92; || &#x5C; ||
|-
| U+005D || &#93; || &#x5D; ||
|-
| U+005E || &#94; || &#x5E; ||
|-
| U+005F || &#95; || &#x5F; ||
|-
| U+0060 || &#96; || &#x60; ||
|-
| U+0061 || &#97; || &#x61; ||
|-
| U+0062 || &#98; || &#x62; ||
|-
| U+0063 || &#99; || &#x63; ||
|-
| U+0064 || &#100; || &#x64; ||
|-
| U+0065 || &#101; || &#x65; ||
|-
| U+0066 || &#102; || &#x66; ||
|-
| U+0067 || &#103; || &#x67; ||
|-
| U+0068 || &#104; || &#x68; ||
|-
| U+0069 || &#105; || &#x69; ||
|-
| U+006A || &#106; || &#x6A; ||
|-
| U+006B || &#107; || &#x6B; ||
|-
| U+006C || &#108; || &#x6C; ||
|-
| U+006D || &#109; || &#x6D; ||
|-
| U+006E || &#110; || &#x6E; ||
|-
| U+006F || &#111; || &#x6F; ||
|-
| U+0070 || &#112; || &#x70; ||
|-
| U+0071 || &#113; || &#x71; ||
|-
| U+0072 || &#114; || &#x72; ||
|-
| U+0073 || &#115; || &#x73; ||
|-
| U+0074 || &#116; || &#x74; ||
|-
| U+0075 || &#117; || &#x75; ||
|-
| U+0076 || &#118; || &#x76; ||
|-
| U+0077 || &#119; || &#x77; ||
|-
| U+0078 || &#120; || &#x78; ||
|-
| U+0079 || &#121; || &#x79; ||
|-
| U+007A || &#122; || &#x7A; ||
|-
| U+007B || &#123; || &#x7B; ||
|-
| U+007C || &#124; || &#x7C; ||
|-
| U+007D || &#125; || &#x7D; ||
|-
| U+007E || &#126; || &#x7E; ||
|}
Line 278 ⟶ 279:
While the syntax of SGML does not prohibit references to invalid or unassigned code points, such as <code>&#xFFFF;</code>, SGML-derived markup languages such as HTML and XML can, and often do, restrict numeric character references to only those code points that are assigned to characters.
Restrictions may also apply for other reasons. For example, in HTML 4, <code>&#12;</code>, which is a reference to a non-printing "form feed" control character, is allowed because a form feed character is allowed. But in XML, the form feed character cannot be used, not even by reference.<ref>{{cite web |title=HTML 5.2: 8. The HTML syntax |url=https://www.w3.org/TR/2017/WD-html52-20170228/syntax.html |website=www.w3.org}}</ref>{{Citation needed|date=May 2013}} As another example, <code>&#128;</code>, which is a reference to another control character, is not allowed to be used or referenced in either HTML or XML, but when used in HTML, it is usually not flagged as an error by web browsers – some of which interpret it as a reference to the character represented by code value 128 in the [[Windows-1252]] encoding for compatibility reasons. This character, "€", has to be represented as <code>&#8364;</code> in a standard-compliant HTML code. As a further example, prior to the publication of XML 1.0 Second Edition on October 6, 2000, XML 1.0 was based on an older version of ISO 10646 and prohibited using characters above U+FFFD, except in character data, thus making a reference like <code>&#65536;</code> (U+10000) illegal. In XML 1.1 and newer editions of XML 1.0, such a reference is allowed, because the available character repertoire was explicitly extended.
Markup languages also place restrictions on where character references can occur.
Line 284 ⟶ 285:
==Compatibility issues==
In the initial versions of [[SGML]] and [[HTML]], numeric character references were interpreted in relationship to the document character encoding, rather than [[Unicode]]. For Latin-script documents, numeric character references to characters between x80 and x9F in those documents will not be correct against [[Unicode]], and must be recoded. HTML standards prior to [[HTML 4]]
For example, as mentioned above, the correct numeric character reference for the [[Euro sign]] "€" <code>U+20AC</code> when using [[Unicode]] is decimal <code>&#8364;</code> and hexadecimal <code>&#x20AC;</code>. However, if using tools supporting obsolete implementations of HTML, the reference <code>&#128;</code> (Euro sign in the [[
As another example, if some text was created originally using the [[MacRoman]] character set, the [[quotation mark
==See also==
Line 295 ⟶ 296:
==References==
{{Reflist}}
{{Unicode navigation}}
|