HP C/iX Reference Manual (31506-90011)
24 Chapter2
Lexical Elements
Character Constants
lowercase x and any number of hexadecimal digits. It is terminated by any
non-hexadecimal characters. The digits of the escape sequences are converted into a single
8-bit character and stored in the character constant at that point. For example, the
following character constants have the same value:
'A' '\101' '\x41'
They all represent the decimal value 65.
Character constants are not restricted to one character; multi-character character
constants are allowed. The value of an integral character constant containing more than
one character is computed by concatenating the 8-bit ASCII code values of the characters,
with the leftmost character being the most significant. For example, the character constant
'AB' has the value 256*'A'+'B' = 256*65+66 = 16706. Only the rightmost four
characters participate in the computation.
Wide character constants (type wchar_t) are of type unsigned int. A wide character
constant is a sequence of one or more multibyte characters enclosed in single quotes and
prefixed by the letter L. The value of a wide character constant containing a single
multibyte character is a member of the extended execution character set whose value
corresponds to that of the multibyte character. The value of a multibyte character can be
found by calling the function mbtowc.
For multi-character wide character constants, the entire content of the constant is
extracted into an unsigned integer and the resulting character is represented by the final
value.
Some characters are given special representation in escape sequences. These are
nonprinting and special characters that programmers often need to use (listed in
<Undefined Cross-Reference> below).
Table 2-1. Special Characters
Character Description
\n New line
\t Horizontal tab
\v Vertical tab
\b Backspace
\r Carriage return
\f Form feed
\\ Backslash character
\' Single quote
\' Double quote
\a Audible or visible alert (control G)
\? Question mark character '?'