Digraph Sequence
You can represent unavailable characters in a source program by using a combination of two keystrokes called a digraph sequence. Digraphs are read as tokens during the preprocessor phase. Digraphs can be created using macro concatenation. They are not replaced in string literals or in character literals.
ISO/ANSI committee recently made a number of additions to the existing set of digraphs. VisualAge C++ supports the new set of digraphs by default.
If you choose not to use the ANSI additions, you
must specify this via the olddigraph
language option.
The following table is a list of the digraphs that were supported in previous versions of VisualAge C++. These digraphs are allowed when the olddigraph language option is set.
| Digraph Sequence | ||
|---|---|---|
| <% | { | left brace |
| %> | } | right brace |
| <: | [ | left bracket |
| :> | ] | right bracket |
| %: | # | pound sign |
| %:%: | ## | preprocessor macro concatentation operator |
New ANSI Digraphs
VisualAge C++ recognizes the complete
set of digraphs defined by ISO/ANSI. The following table is the
complete set of digraphs defined by ISO/ANSI.
| Digraph Sequence | ||
|---|---|---|
| <% | { | left brace |
| %> | } | right brace |
| <: | [ | left bracket |
| :> | ] | right bracket |
| %: | # | pound sign |
| %:%: | ## | preprocessor macro concatentation operator |
| and | && | conditional and (dual ampersand) |
| bitor | | | pipe |
| or | || | conditional or (dual pipe) |
| xor | ^ | caret |
| compl | ~ | tilde |
| bitand | & | ampersand |
| and_eq | &= | ampersand-equal |
| or_eq | |= | pipe-equal |
| xor_eq | ^= | caret-equal |
| not | ! | exclamation mark |
| not_eq | != | exclamation mark-equal |
![]()
![]()
For C, the new
digraphs added by ISO/ANSI are included in the iso646.h header
file.
![]()
For AIX, the
iso646.h is not available for C.
Trigraph Sequence
Some characters from the C character set
are not available in all environments. You can enter these
characters into a C source program using a sequence of three
characters called a trigraph. The trigraph sequence are:
| Trigraph Sequence | ||
|---|---|---|
| ??= | # | pound sign |
| ??( | [ | left bracket |
| ??) | ] | right bracket |
| ??< | { | left brace |
| ??> | } | right brace |
| ??/ | \ | backslash |
| ??' | ^ | caret |
| ??! | | | pipe |
| ??- | ~ | tilde |
The preprocessor replaces trigraph sequence with the corresponding single-character representation.
Escape Sequence
An escape sequence contains a backslash
(\) symbol followed by one of theescape sequence characters or an
octal or hexadecimal number. A hexidecimal escape sequence
contains an x followed by one or more hexadecimal digits (0-9,
A-F, a-f). AN octal escape sequence uses up to three octal digits
(0-7).
Note: The line continuation sequence (\ followed by a new line character) is not an escape sequence. It is used in character strings to indicate that the current line continues on the next line.
| Escape Sequence | ||
|---|---|---|
| new-line | NL (LF) | \n |
| horizontal tab | HT | \t |
| vertical tab | VT | \v |
| backspace | BS | \b |
| carriage return | CR | \r |
| form feed | FF | \f |
| alert | BEL | \a |
| backslash | \ | \\ |
| question mark | ? | \? |
| single quote | ' | \' |
| double quote | " | \" |
| octal number | ooo | \ooo |
| hex number | hhh | \hhh |
