Main Page | See live article | Alphabetical index

Trigraph (computing)

A trigraph is a sequence of three characters that represents a single character.

The character set of the C programming language is contained within the 7-bit ASCII character set, but is a superset of the ISO 646-1983 Invariant Code Set. To enable programs to be represented in this reduced character set, the preprocessor replaces all occurrences of the following trigraph sequences by their single-character equivalents before any other processing:

    Trigraph     Equivalent
    
">

">

??= # ??/ \\ ??' ^ ??( [ ??) ] ??! | ??< { ??> } ??- ~

This feature of C language is obsolete today, and many compilers either have an option to turn recognition of trigraphs off, or disable trigraphs by default and have an option to turn them on.

To enter two question marks, one has to use an escape sequence such as "?\\?". The only places in the grammar of C where it would be apropriate to have two question marks in a row would be in character constants, string literals, and comments.