Different systems define different sets of digraphs and trigraphs, as described below.
ALGOL Early versions of
ALGOL predated the standardized ASCII and EBCDIC character sets, and were typically implemented using a manufacturer-specific
six-bit character code. A number of ALGOL operations either lacked
codepoints in the available character set or were not supported by peripherals, leading to a number of substitutions including := for ← (assignment) and >= for ≥ (greater than or equal).
Pascal The
Pascal programming language supports digraphs (., .), (* and *) for [, ], { and } respectively. Unlike all other cases mentioned here, (* and *) were and still are in wide use. However, many compilers treat them as a different type of commenting block rather than as actual digraphs, that is, a comment started with (* cannot be closed with } and vice versa.
J The
J programming language is a descendant of
APL but uses the ASCII character set rather than
APL symbols. Because the printable range of ASCII is smaller than APL's specialized set of symbols, . (dot) and : (colon) characters are used to inflect ASCII symbols, effectively interpreting unigraphs, digraphs or rarely trigraphs as standalone "symbols".). To safely place two consecutive question marks within a string literal, the programmer can use string concatenation "...?""?..." or an
escape sequence "...?\?...". ??? is not itself a trigraph sequence, but when followed by a character such as - it will be interpreted as ? + ??-, which becomes ?~. The ??/ trigraph can be used to introduce an escaped newline for line splicing; this must be taken into account for correct and efficient handling of trigraphs within the preprocessor. It can also cause surprises, particularly within comments. For example: which is a single logical comment line (used in C++ and
C99), and which is a correctly formed block comment. The concept can be used to check for trigraphs as in the following C99 example, where only one return statement will be executed. {{sxhl|2=c|1= // returns false or true; language standard C99 or later bool trigraphsAvailable() { // are trigraphs available??/ return false; return true; } }} In 1994, a normative amendment to the C standard,
C95, included in C99, supplied digraphs as more readable alternatives to five of the trigraphs. Unlike trigraphs, digraphs are handled during
tokenization, and any digraph must always represent a full token by itself, or compose the token %:%: replacing the preprocessor concatenation token ##. If a digraph sequence occurs inside another token, for example a quoted string, or a character constant, it will not be replaced.
C++ C++ (through
C++14, see
below) behaves like C, including the C99 additions. As a note, %:%: is treated as a single token, rather than two occurrences of %:. In the sequence if the subsequent character is neither : nor >, the is treated as a preprocessing token by itself and not as the first character of the alternative token . This is done so certain uses of templates are not broken by the substitution. The C++ Standard makes this comment with regards to the term "digraph": Trigraphs were proposed for deprecation in
C++0x, which was released as
C++11. This was opposed by
IBM, speaking on behalf of itself and other users of C++, and as a result trigraphs were retained in C++11. Trigraphs were then proposed again for removal (not only deprecation) in
C++17. This passed a committee vote, and trigraphs (but not the additional tokens) are removed from C++17 despite the opposition from IBM. Existing code that uses trigraphs can be supported by translating from the source files (parsing trigraphs) to the basic source character set that does not include trigraphs.
RPL Hewlett-Packard calculators supporting the
RPL language and input method provide support for a large number of trigraphs (also called
TIO codes) to reliably transcribe non-seven-bit ASCII characters of the
calculators' extended character set on foreign platforms, and to ease keyboard input without using the application. The first character of all TIO codes is a \, followed by two other ASCII characters vaguely resembling the glyph to be substituted. All other characters can be entered using the special \nnn TIO code syntax with nnn being a three-digit
decimal number (with
leading zeros if necessary) of the corresponding
code point (thereby formally representing a
tetragraph). == Application support ==