Trigraph
A trigraph is a graph that consists of a sequence of three glyphs and represents a phoneme.
Linguistics
In linguistics, a trigraph is a combination of three letters that are treated phonetically as a unit and represent a single sound.
Programming language C
The programming language C uses almost the entire ASCII character set.
This can lead to the following problems:
- Some characters cannot be entered using the keyboard or can only be entered with difficulty, especially with many older non-US keyboard layouts.
- In some character sets, e.g. B. national variants according to ISO 646 , these characters are not available, or they are coded differently (as in the different variants of EBCDIC ), so that interoperability problems can arise when exchanging files.
That is why nine three-character sequences were defined in C, which are called trigraphs. They all start with ??
, followed by another character:
Trigraph | substituted character |
---|---|
??= |
#
|
??/ |
\
|
??' |
^
|
??( |
[
|
??) |
]
|
??! |
|
|
??< |
{
|
??> |
}
|
??- |
~
|
Since the late 1980s there is no longer any need to use trigraphs in C, as all special characters are now available on keyboards and ASCII or Unicode have established themselves as the standard.
C ++
The same trigraphs also existed in C ++, but were considered obsolete since C ++ 11 and were removed with C ++ 17 . In C ++ there are also so-called digraphs and "alternative notations" for some operators, which also avoid the critical characters. In contrast to the digraphs and alternative notations, which can only be used where a token is expected, the nine trigraphs were replaced by the corresponding simple characters before every other processing step and everywhere in the program text - especially in character and character strings . Constants :
puts("Bitte Kennnummer eingeben (im Format ??-???-??)");
The output is then:
Bitte Kennnummer eingeben (im Format ~?~]
because of the substitution of the trigraphs ?? - and ??) in the string.
Web links
Individual evidence
- ↑ British Standards Institute (ed.): The C Standard - Incorporating TC1 - BS ISO / IEC 9899: 1999 . John Wiley & Sons, 2003, ISBN 0-470-84573-2 , 5.2.1.1.
- ^ Rationale for C99, Revision 5.10. (PDF; 898 kB) Retrieved October 17, 2010 (English, Section 5.2.1.1).
- ↑ en.cppreference.com