Escape sequence

An escape sequence (after the escape character, english to escape, get out ') is a combination of characters in the technical computer science, which does not represent a text, but is intercepted by the device and performs a special function. In a display terminal, this can for example be the cursor positioning, in a printer switching to a different font size or ejection of the page.

Operation

The name is derived from the character with which the sequence is usually initiated; the ESC character ( ASCII character set hexadecimal code 1B, decimal 27 ), which was used as the escape character between normal meaning of the characters and special function since 1968 at the latest.

The respective program - regardless of whether it is an application for desktop computer or a control program in a peripheral device - detects when processing a string, for example a text, the escape character, gets out of the normal processing and triggers the following character sequence assigned from special function. Then normal processing continues. During the processing of the text, however, for example in a text editor, an escape character remains as ordinary characters uninterpreted and thus does not trigger function. A special case are WYSIWYG programs to which, for example, modern word processing programs include, where the display corresponds directly to the issue with all the special features.

In order to represent non- printable control characters in the source code in programming, certain sequences of printable characters is given the meaning of a special function by a (nother ) is preceded by certain characters, which serves as a wildcard character. Thus, in the C programming language within a string constant such as a \ n for a newline, \ t to a tab character and \ "for a quote ( while the simple" is not part of a string constants, but the end thereof referred to ). Such a string is in transferring the old function name also called escape sequence, although the real ESC character here are no longer used. Similarly, Microsoft Word in the editing function " find and replace " the character ^ is used, for example, ^ t for the tab.

Use the printer control

As before, escape sequences in the control of printers are used. Examples of widespread escape sequence - based printer languages ​​are:

  • ESC / P ( Epson)
  • PCL ( Hewlett -Packard)

Some printers, however, are not working with escape sequences, but for example with page description languages ​​such as PostScript or receive commands via a separate control address on the bus (eg for Commodore computers ).

Use for terminal handling

In the terminal area, the ANSI escape sequences, which are based on the escape sequences of the terminal VT100 widespread. They were known as ANSI X3.41 -1974 and X3.64 -1977 general standard. Sequences consist of the control characters and escape a sequence of printable characters.

Examples: ESC c ( terminal reset), ESC [ K ( erase line from cursor ) ESC [ PnA (n is a decimal number, cursor ( n ) lines up). This standard was so popular that console driver as ANSI.SYS for MS- DOS and OS / 2, the virtual consoles and terminal window of most Unix-like operating systems ( such as Mac OS X and Linux) or the shell of the AmigaOS this sequences also support.

In C and related programming languages

In C and C related languages ​​such as C , C #, Java, awk, Perl and JavaScript frequently used control characters in strings by the following escape sequences are inserted (although not all languages ​​support all sequences listed here). The names of many control characters date back to the time, carried as expenditure mainly on telex machines and printers.

An escape character for a higher level of interpretation, see above. Not part of ISO C and ISO C

Due to the influence of strong popular C programming language, the same escape sequences found in other contexts, again, such as in some configuration files.

82513
de