Digraphs and trigraphs
From Seo Wiki - Search Engine Optimization and Programming Languages
| This article needs additional citations for verification.
Please help improve this article by adding reliable references. Unsourced material may be challenged and removed. (September 2008) </td>
Various reasons exist for using digraphs and trigraphs: keyboards may not have keys to cover the entire character set of the language, input of special characters may be difficult, text editors may reserve some characters for special use and so on. Trigraphs might also be used for some EBCDIC code pages that lack characters such as
The basic character set of the C programming language is a subset of the ASCII character set that includes nine characters which lie outside the ISO 646 invariant character set. This can pose a problem for writing source code when the keyboard being used does not support any of these nine characters. The ANSI C committee invented trigraphs as a way of entering source code using keyboards that support any version of the ISO 646 character set.
Trigraphs are not commonly encountered outside compiler test suites. Some compilers support an option to turn recognition of trigraphs off, or disable trigraphs by default and require an option to turn them on. Some can issue warnings when they encounter trigraphs in source files. Borland supplied a separate program, the trigraph preprocessor, to be used only when trigraph processing is desired (the rationale was to maximise speed of compilation).
Different systems have different sets of defined trigraphs:
The C preprocessor replaces all occurrences of the following nine trigraph sequences by their single-character equivalents before any other processing.
A programmer may want to place two question marks together yet not have the compiler treat them as introducing a trigraph. The C grammar does not permit two consecutive
// Will the next line be executed????????????????/ a++;
which is a single logical comment line (used in C++ and C99), and
/??/ * A comment *??/ /
which is a correctly formed block comment.
In 1994 a normative amendment to the C standard, included in C99, supplied digraphs as more readable alternatives to six of the trigraphs. They are:
Unlike trigraphs, digraphs are handled during tokenization, and it must always represent a full token by itself. If a digraph sequence occurs inside another token, for example a quoted string, or a character constant, it will not be replaced.