Escape sequence (original) (raw)
An escape sequence is a series of characters used to trigger some sort of command state in computers and their attached peripherals.
It is commonly used when the computer and the peripheral have only a single channel in which to send information back and forth. If the device in question is "dumb" and can only do one thing with the information being sent to it (for instance, print it) then there is no need for an escape sequence. However most devices have more than one capability, and thus need some way to tell data from commands.
For instance the Hayes AT command set defines a single escape sequence, +++. When the modem encounters this in a stream of data, it switches from its normal mode of operation which simply sends any characters to the phone, to a command mode in which the following data is assumed to be a part of the command language. You can switch back to the online mode by sending the O command.
The Hayes command set is modal, switching from command mode to online mode. This is not appropriate in the case where the commands and data will switch back and forth rapidly. An example of a non-modal escape sequence control language is the VT100, which used a series of commands prefixed by the Control Sequence Introducer, escape-[.
There is a fine line between a set of control characters and an escape sequence that may not exist at all. The earlier VT52 terminal used simple commands like escape-A, which is sufficiently simple to be considered a control character command language. However the VT52 also supported parameters, which a simple control language likely wouldn't.