Escape sequence

Escape sequence
This article refers to codes used as commands for computing devices. Escape sequence can also refer to a sequence of escape characters used in parsing source code.

An escape sequence is a series of characters used to change the state of computers and their attached peripheral devices. These are also known as control sequences, reflecting their use in device control. Some control sequences are special characters that always have the same meaning. Escape sequences use an escape character to change the meaning of the characters which follow it, meaning that the characters can be interpreted as a command to be executed rather than as data.

Escape sequences are commonly used when a computer and a peripheral have only a single channel through 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 distinguish information that is to be treated as data from information that is to be treated as commands.

An 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. For example, the Esc key may be used as an input character in editors such as EMACS, or for backing up one level in a menu in some applications. 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.

If the Esc key and other keys that send escape sequences are both supposed to be meaningful to an application, an ambiguity arises, if a terminal or terminal emulator is in use. In particular, when the application receives the ASCII escape character, it is not clear whether that character is the result of the user pressing the Esc key or whether it is the initial character of an escape sequence (e.g., resulting from an arrow key press). The traditional method of resolving the ambiguity is to observe whether or not another character quickly follows the escape character. If not, it is assumed not to be part of an escape sequence. This heuristic can fail under some circumstances, but in practice it works reasonably well, especially with faster modern communication speeds.

Escape sequences date back at least to the 1874 Baudot code.[citation needed]

Contents

Modem control

The Hayes command set, for instance, defines a single escape sequence, +++. (In order not to interpret +++ which may be a part of data as the escape sequence the sender stops communication for one second before and after the +++) .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-[.

Comparison with control characters

A control character is a character that, in isolation, has some control function, such as carriage return (CR). Escape sequences, by contrast, consist of an escape character or sequence which changes the interpretation of following characters.

The earlier VT52 terminal used simple digraph commands like escape-A: in isolation, "A" simply meant the letter "A", but as part of the escape sequence "escape-A", it had a different meaning. The VT52 also supported parameters: it was not a straightforward control language encoded as substitution.

ASCII video data terminals

The VT100 terminal implemented the more sophisticated ANSI standard (now ECMA-48) for functions such as controlling cursor movement, character set, and display enhancements. The Hewlett Packard HP 2640 series had perhaps the most elaborate escape sequences for block and character modes, programming keys and their soft labels, graphics vectors, and even saving data to tape or disk files.

Use in DOS and Windows

A utility, ANSI.SYS, can be used to enable the interpreting of the ANSI (ECMA-48) terminal escape sequences in a DOS command window in DOS or 16-bit Windows. The rise of GUI applications, which directly write to display cards, has greatly reduced the usage of escape sequences on Microsoft platforms, but they can still be used to create interactive random-access character-based screen interfaces with the character-based library routines such as printf without resorting to a GUI program.

See also


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • escape sequence — noun (computing) A sequence of characters, usu beginning with an escape character, that gives or initiates a command • • • Main Entry: ↑escape …   Useful english dictionary

  • escape sequence — kaitos seka statusas T sritis informatika apibrėžtis Tekste esanti ženklų seka, kuri turi būti interpretuojama kitaip negu įprasta: kaip komanda, kaip vienas ženklas, kurio nėra naudojamoje koduotėje, ir pan. Plačiau žr. priede. priedas( ai) MS… …   Enciklopedinis kompiuterijos žodynas

  • escape sequence —    A sequence of characters, beginning with Escape (ASCII 27) and followed by one or more other characters, that performs a specific function. Sometimes called an escape code. Escape sequences are often used to control printers or monitors, which …   Dictionary of networking

  • escape sequence — noun An escape character together with the subsequent characters that specify a particular meaning …   Wiktionary

  • Time Independent Escape Sequence — The Time Independent Escape Sequence, or TIES, was a short lived modem standard invented to avoid a patent held by Hayes Microcomputer Products. TIES was an escape sequence that switched the modem from data mode to command mode , allowing… …   Wikipedia

  • Escape — may refer to: * Escape (hold), a maneuver used to exit a wrestling or grappling hold * Escapism, mental diversion by means of entertainment or recreation * Escapology, the study and practice of escaping from physical restraints * Prison escape,… …   Wikipedia

  • Escape-последовательность — («исключённая последовательность», «экранированная последовательность»)  совокупность идущих подряд значащих элементов, в группе теряющих для обрабатывающего механизма своё индивидуальное значение, одновременно с приобретением этой группой… …   Википедия

  • Escape character — 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… …   Wikipedia

  • escape character — noun A single metacharacter, usually a control code, which in a sequence of characters signifies that what is to follow takes an alternative interpretation. The term escape sequence refers to the escape character and the subsequent character or… …   Wiktionary

  • Sequence (filmmaking) — In film, a sequence is a series of scenes which form a distinct narrative unit, usually connected either by unity of location or unity of time. For example a heist film might include an extended recruitment sequence in which the leader of the… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”