

The Hewlett Packard HP 2640 terminals had a key for a "display functions" mode which would display graphics for all control characters, including Esc, to aid in debugging applications. For example, the Esc key may be used as an input character in editors such as vi, or for backing up one level in a menu in some applications. Even relatively "dumb" terminals responded to some escape sequences, including the original mechanical Teletype printers (on which "glass Teletypes" or VDUs were based) responded to characters 27 and 31 to alternate between letters and figures modes.Īn escape character is usually assigned to the Esc key on a computer keyboard, and can be sent in other ways than as part of an escape sequence. They were common when most dumb terminals used ASCII with 7 data bits for communication, and sometimes would be used to switch to a different character set for "foreign" or graphics characters that would otherwise been restricted by the 128 codes available in 7 data bits.
#C language ansi escape sequences code#
With the introduction of ANSI terminals most escape sequences began with the two characters "ESC" then "[" or a specially-allocated CSI character with a code 155 (decimal).
#C language ansi escape sequences series#
When directed this series of characters is used to change the state of computers and their attached peripheral devices, rather than to be displayed or printed as regular data bytes would be, these are also known as control sequences, reflecting their use in device control, beginning with the Control Sequence Initiator - originally the "escape character" ASCII code - character 27 (decimal) - often written "Esc" on keycaps. For devices that respond to ANSI escape sequences, the combination of three or more characters beginning with the ASCII "escape" character (decimal character code 27) followed by the left-bracket character [ (decimal character code 91) defines an escape sequence.Assuming ASCII encoding, the escape sequences \x5c ( hexadecimal), \\, \134 ( octal) and \x5C all encode the same character: the backslash \. A character may be escaped in multiple different ways.To represent the backslash character itself, \\ can be used, whereby the first backslash indicates an escape and the second specifies that a backslash is being escaped.Note that in C a backslash immediately followed by a newline does not constitute an escape sequence, but splices physical source lines into logical ones in the second translation phase, whereas string escape sequences are converted in the fifth translation phase.In C and many derivative programming languages, a string escape sequence is a series of two or more characters, starting with a backslash \.In computer science, an escape sequence is a combination of characters that has a meaning other than the literal characters contained therein it is marked by one or more preceding (and possibly terminating) characters. Character combinations with ulterior meaning
