Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Trigraph

created by Webster 1913

(thing) by Wog (2.4 y) (print)   ?   (I like it!) Sun Jun 03 2001 at 22:20:37

In C, a trigraph is a special three character sequence that maps to another character. The intent of trigraphs is to support machines which have character sets which do not have certain characters. (Specifically the ones not in ISO 646-1983 Invariant Code Set.)

The trigraphs are:

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

Trigraph replacements can occur anywhere.

For example:


??=include <stdio.h>

void prompt(int x, int y)

??<

  printf("??= %d + %d? ", x, y);

??>

is actually the same as


#include <stdio.h>

void prompt(int x, int y)

{

  printf("# %d + %d? ", x, y);

}

Trigraphs are usually not seen outside of obfuscated code. In fact, GCC discourages its use by requiring it be run in strict ANSI conformance mode (the -ansi option) or with the special -trigraphs option for trigraphs to work. In fact, concerning them the GCC texinfo documentation says: "You don't want to know about this brain-damage".

Apparently as a result of the dislike of trigraphs, "digraphs" were added to the C standard, which are alternate spellings of certain tokens, avoiding unexpected expansion in strings. Also, they tend to be easier to read. However, there are no digraphs for |, ~, ^, and \. However, the first three can now be made up for with iso646.h's alternate names for operators.

With help from "The C Programming Language, Second Edition" (by Brain W. Kernighan and Dennis M. Ritche), and a recent draft of the C standard.


(definition) by Webster 1913 (print) Wed Dec 22 1999 at 3:55:54

Tri"graph (?), n. [Pref. tri- + -graph.]

Three letters united in pronunciation so as to have but one sound, or to form but one syllable, as -ieu in adieu; a triphthong.

 

© Webster 1913.


printable version
chaos

digraph iso646.h The C Programming Language triphthong
## Analyzing spam: A journey into conspiracy theory and steganography ISO-646 8th grade
Roswell IOCCC ISO C Himilco
C99 Neil Peart strings character set
Babylon 5 DPMI Trigram Dysfunctional spelling
ANSI
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
What you are reading:
Green Goddess
Concert etiquette
Keeping your data from the FBI
The Amityville Horror
classroom management
Take me from home
Fear of genetically altered food unfounded
Robert Lionel Fanthorpe
Medea
lasagne
augmented triad
spleen
John Walker Lindh
New Writeups
aneurin
You pays your money and you takes your choice(idea)
shaogo
July 20, 2008(log)
Glowing Fish
Tualatin River(place)
The Jacket
Words of Advice(idea)
John_Fox
Good Intentions Gone Wrong(person)
Heitah
Posthumous Oscar(thing)
ignis_glaciesque
University of South Florida(place)
ignis_glaciesque
Flogstaskriket(idea)
liveforever
Caesar's last breath(idea)
dagnyswaggart
she wants to believe(personal)
antigravpussy
he doesn't know, but her eyes widen too far(thing)
dagnyswaggart
Wild tides guard her secrets(poetry)
Lord Brawl
Caesar's last breath(poetry)
locke baron
Forgotten things in space(fiction)
sitaraika
Colours(idea)
Everything 2 is brought to you by the letter C and The Everything Development Company