5 Lexical conventions [lex]

5.3 Character sets [lex.charset]

The translation character set consists of the following elements:
  • each character named by ISO/IEC 10646, as identified by its unique UCS scalar value, and
  • a distinct character for each UCS scalar value where no named character is assigned.
[Note 1:
ISO/IEC 10646 code points are integers in the range (hexadecimal).
A surrogate code point is a value in the range (hexadecimal).
A UCS scalar value is any code point that is not a surrogate code point.
— end note]
The basic character set is a subset of the translation character set, consisting of 96 characters as specified in Table 1.
[Note 2:
Unicode short names are given only as a means to identifying the character; the numerical value has no other meaning in this context.
— end note]
Table 1: Basic character set [tab:lex.charset.basic]
character
glyph
U+0009
CHARACTER TABULATION
U+000B
LINE TABULATION
U+000C
FORM FEED (FF)
U+0020
SPACE
U+000A
LINE FEED (LF)
new-line
U+0021
EXCLAMATION MARK
!
U+0022
QUOTATION MARK
"
U+0023
NUMBER SIGN
#
U+0025
PERCENT SIGN
%
U+0026
AMPERSAND
&
U+0027
APOSTROPHE
'
U+0028
LEFT PARENTHESIS
(
U+0029
RIGHT PARENTHESIS
)
U+002A
ASTERISK
*
U+002B
PLUS SIGN
+
U+002C
COMMA
,
U+002D
HYPHEN-MINUS
-
U+002E
FULL STOP
.
U+002F
SOLIDUS
/
U+0030 ..
U+0039
DIGIT ZERO ..
NINE
0 1 2 3 4 5 6 7 8 9
U+003A
COLON
:
U+003B
SEMICOLON
;
U+003C
LESS-THAN SIGN
<
U+003D
EQUALS SIGN
=
U+003E
GREATER-THAN SIGN
>
U+003F
QUESTION MARK
?
U+0041 ..
U+005A
LATIN CAPITAL LETTER A ..
Z
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
U+005B
LEFT SQUARE BRACKET
[
U+005C
REVERSE SOLIDUS
\
U+005D
RIGHT SQUARE BRACKET
]
U+005E
CIRCUMFLEX ACCENT
^
U+005F
LOW LINE
U+0061 ..
U+007A
LATIN SMALL LETTER A ..
Z
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
U+007B
LEFT CURLY BRACKET
{
U+007C
VERTICAL LINE
|
U+007D
RIGHT CURLY BRACKET
}
U+007E
TILDE
~
The universal-character-name construct provides a way to name other characters.
A universal-character-name designates the character in the translation character set whose UCS scalar value is the hexadecimal number represented by the sequence of hexadecimal-digits in the universal-character-name.
The program is ill-formed if that number is not a UCS scalar value.
If a universal-character-name outside the c-char-sequence, s-char-sequence, or r-char-sequence of a character-literal or string-literal (in either case, including within a user-defined-literal) corresponds to a control character or to a character in the basic character set, the program is ill-formed.
[Note 3:
A sequence of characters resembling a universal-character-name in an r-char-sequence ([lex.string]) does not form a universal-character-name.
— end note]
The basic literal character set consists of all characters of the basic character set, plus the control characters specified in Table 2.
Table 2: Additional control characters in the basic literal character set [tab:lex.charset.literal]
character
U+0000
NULL
U+0007
BELL
U+0008
BACKSPACE
U+000D
CARRIAGE RETURN (CR)
A code unit is an integer value of character type ([basic.fundamental]).
Characters in a character-literal other than a multicharacter or non-encodable character literal or in a string-literal are encoded as a sequence of one or more code units, as determined by the encoding-prefix ([lex.ccon], [lex.string]); this is termed the respective literal encoding.
The ordinary literal encoding is the encoding applied to an ordinary character or string literal.
The wide literal encoding is the encoding applied to a wide character or string literal.
A literal encoding or a locale-specific encoding of one of the execution character sets ([character.seq]) encodes each element of the basic literal character set as a single code unit with non-negative value, distinct from the code unit for any other such element.
[Note 4:
A character not in the basic literal character set can be encoded with more than one code unit; the value of such a code unit can be the same as that of a code unit for an element of the basic literal character set.
— end note]
The U+0000 NULL character is encoded as the value 0.
No other element of the translation character set is encoded with a code unit of value 0.
The code unit value of each decimal digit character after the digit 0 (U+0030) shall be one greater than the value of the previous.
The ordinary and wide literal encodings are otherwise implementation-defined.
For a UTF-8, UTF-16, or UTF-32 literal, the UCS scalar value corresponding to each character of the translation character set is encoded as specified in ISO/IEC 10646 for the respective UCS encoding form.