Tuesday, August 05, 2008

\x1b in C

These are guaranteed by the Standard:

\a is alert (whether this means a bleep, a flash, or something else, is
implementation-dependant).
\b is backspace.
\f is form feed.
\n is new line. It is the character which represents a new line in files
opened in text mode.
\r is carriage return.
\t is a horizontal tab. Size depends on the implementation.
\v is a vertical tab, whatever that is on modern devices.
\' is a literal single quote mark.
\" is a literal double quote mark.
\? is a literal question mark (trigrahps, avoidance, ftpo).
\\ is a literal backslash.

\ is the character represented by that octal number, and
\x is the character represented by that hexadecimal number.
The only ones of these of which you reliably know the meaning are
\0, \x0, and equivalent, all of which are character 0, the null
character.

\x1b, as you mention above, is the character with hex value 1b, i.e.
decimal 27. This may or may not represent ESC. It is the character point
for ESC in a very common character set; whether this means that your
implementation also transmits it as an Escape, and whether the OS then
does something sensible with it, is up to them. The Standard neither
does nor reasonably can require it.

0 comments: