A character literal is a pair of single quotes enclosing either a single
ISO-Latin-1 printing character (excluding single quote) or an escape sequence.
The type of a character literal is CHAR
.
A text literal is a pair of double quotes enclosing a sequence of ISO-Latin-1
printing characters (excluding double quote) and escape sequences. The type
of a text literal is TEXT
.
Here are are the legal escape sequences and the characters they denote:
A
\n
newline (linefeed) \f
form feed \t
tab \\
backslash \r
carriage return \"
double quote \'
single quote \nnn
char with code 8_nnn
\Xnn
char with code 16_nn
\
followed by exactly three octal digits specifies the character
whose code is that octal value.
A \x
followed by exactly two hexadecimal digits specifies the character
whose code is that hexadecimal value.
The hexadecimal digits are case-insensitive.
The 'X' in a hexadecimal escape sequence is case-insensitive.
A \
that is not a part of one of these
escape sequences is a static error.
A wide character literal has the form W charlit
, where charlit
is like a character literal, except that an octal escape sequence
within must have exactly six octal digits and a hexadecimal escape
sequence within must have exactly four hexadecimal digits. The type of
a wide character literal is WIDECHAR
.
The leading 'W' is case-insensitive.
Similarly, a wide text literal has the form W textlit
,
where textlit
is like a text literal, except any octal or hexadecimal
escape sequences within must have exactly six octal or four hexadecimal
digits, respectively.
Unlike character literals, ordinary text literals and wide text literals
both have the type TEXT
, differing only in the method of specifying
the literal's value.
The leading 'W' is case-insensitive.
For example, 'a'
and '\''
are valid character literals,
'''
is not; ""
and "Don't\n"
are valid text literals,
"""
is not.
m3-support@elego.de