Electrical engineering

escape sequence

An escape character together with subsequent characters, not output as written, but specifying a particular behaviour.

escape sequence: code that tells equipment to do something else

An escape sequence is a string of characters that instructs a device or system to perform an action other than displaying or printing those characters literally. It begins with a special character, typically the ASCII escape character (hex 1B, decimal 27), followed by one or more additional characters that define the desired behavior. The receiving equipment interprets the entire sequence as a command rather than text.

In electrical engineering and industrial control systems, escape sequences are used extensively in terminal interfaces, programmable logic controllers (PLCs), and serial communications. A common example is the ANSI escape sequence, which controls text formatting on terminal displays: the sequence ESC[31m instructs a terminal to switch text color to red. Another standard is the escape sequence for bell or alert: ESC G in some legacy systems triggers an audible alarm. Industrial printers and label makers use escape sequences to switch fonts, adjust print density, or control paper feed.

Variants and protocols

Different equipment families recognize different escape sequence dialects. VT100 terminal emulation sequences (from the Digital Equipment Corporation standard) remain widespread in industrial settings and use the format ESC followed by a bracket and alphanumeric parameters. Printer control languages such as ESC/P (Epson Standard Code for Printers) define sequences for margins, line spacing, and print mode. RS-232 serial devices may use proprietary sequences specific to their manufacturer. Unicode and UTF-8 environments use different escape conventions entirely, embedding escape sequences within multi-byte character encodings.

Problems arise when a system receives an escape sequence it does not recognize or when data containing byte sequences that resemble escape characters is mistakenly interpreted as a command. A corrupted serial link or incorrect terminal type setting can cause readable text to become garbled control codes. Legacy equipment often relies on specific escape sequence dialogs; replacing or patching such systems requires careful verification that new firmware or drivers generate identical sequences.

The name derives from the typist's experience on mechanical teletypes: the escape key on early keyboards signaled that the following characters should be interpreted as a special instruction rather than ordinary text to be printed. This convention persisted into electronic systems and remains the basis for escape sequence architecture in modern industrial equipment, from CNC machines to networked instrument displays.

More from Electrical engineering

See all

Get the Word of the Day

One industrial term every weekday, with the trade it belongs to and why it is worth knowing. No advertising.