Escape character

related topics
{math, number, function}
{system, computer, user}
{film, series, show}
{language, word, form}
{work, book, publish}
{day, year, event}

In computing and telecommunication, an escape character is a character which invokes an alternative interpretation on subsequent characters in a character sequence. An escape character is a particular case of metacharacters. Generally, the judgement of whether something is an escape character or not depends on context.



Escape characters are part of the syntax for many programming languages, data formats and communication protocols. For a given alphabet an escape character's purpose is to start character sequences (so named escape sequences) which have to be interpreted differently from the same characters occurring alone. An escape character may not have its own meaning, so all escape sequences are of 2 or more characters.

There are usually two functions of escape sequences. The first is to encode a syntactic entity, such as device commands or special data which cannot be directly represented by the alphabet. The second use, referred to as character quoting, is to represent characters which cannot be typed in current context, or would have an undesired interpretation. In the latter case an escape sequence is a digraph consisting of an escape character itself and a "quoted" character.

Escape character vs control character

Generally, an escape character is not a particular case of (device) control characters, nor vice versa. If we define control characters as non-graphic, or as having a special meaning for an output device (e.g. printer or text terminal) then any escape character for this device is a control one. But escape characters used in programming (see below) are graphic, hence are not control characters. Conversely most (but not all) of the ASCII "control characters" have some control function in isolation, therefore are not escape characters.


ASCII escape character

The ASCII "escape" character (octal: \033, or ^[, or, in decimal, 27) is used in many output devices to start a series of characters called a "control sequence" or "escape sequence". Typically, the escape character was sent first in such a sequence to alert the device that the following characters were to be interpreted as a control sequence rather than as plain characters, then one or more characters would follow to specify some detailed action, after which the device would go back to interpreting characters normally. For example, the sequence of ^[, followed by the printable characters [2;10H, would cause a DEC VT102 terminal to move its cursor to the 10th cell of the 2nd line of the screen. This was later developed to ANSI escape codes covered by the ANSI X3.64 standard.

Full article ▸

related documents
Random access
Name server
ABC (programming language)
Filter (Unix)
Dia (software)
Common Language Runtime
Grid network
Data stream
Dining cryptographers protocol
Longitudinal redundancy check
Bit error ratio
Common Language Infrastructure
Andrew Tridgell
Common Intermediate Language
Typed link
Binary symmetric channel
Abbreviated Test Language for All Systems
A-law algorithm
Sequential access
Entropy encoding
Metcalfe's law
Netwide Assembler