Escape sequence
In computing, an escape sequence is a sequence of characters that has a special semantic meaning based on an established convention that specifies an escape character prefix in addition to the syntax of the rest of the text of a sequence. A convention can define any particular character code as a sequence prefix. Some conventions use a normal, printable character such as backslash (\) or ampersand (&). Others use a non-printable (a.k.a. control) character such as ASCII escape. Escape sequences date back at least to the 1874 Baudot code.
In computing, an escape sequence is a sequence of characters that has a special semantic meaning based on an established convention that specifies an escape character prefix in addition to the syntax of the rest of the text of a sequence. A convention can define any particular character code as a sequence prefix. Some conventions use a normal, printable character such as backslash (\) or ampersand (&). Others use a non-printable (a.k.a. control) character such as ASCII escape. Escape sequences date back at least to the 1874 Baudot code. ==Examples== ===Data transmission=== A common use of an escape sequence is to remove control characters from a data stream so that it does not cause its control function by mistake. The control character is replaced with an escape character and one or more other subsequent characters. After escaping the normal context in which the control character would have caused an action, the sequence is replaced by the removed character. To transmit the escape character itself, two copies are sent. ===Text literal=== An escape sequence is often used in character and string literals, to express characters that are not printable or clash with the syntax of characters or strings. For example, control characters might not be allowed in a source file or may have undesirable side-effects if typed into a command. A feature of C and many programming languages influenced by it is that the beginning of an escape sequence in such text literals is marked by a backslash ( \ ). Common examples of these C-style escape sequences include , and for the carriage return, newline, and tab characters, respectively. To account for the fact that using a printable character for escape causes that character to lose its normal meaning, a sequence of two backslash characters ( \\ ) is provided to express a single backslash. There is also an escape sequence that expresses any character by its ASCII-code value. For example, the backslash can be expressed as either \x5c or \134 , which specify the character code value in hexadecimal and octal notations, respectively. Likewise, the lowercase e can be expressed as \145 and the digit 7 as \067 . A backslash immediately followed by a newline (which is necessarily outside of a string literal) does not mark an escape sequence. Instead, it can be thought of as meaning "Disregard the newline": the C preprocessor joins the line with the subsequent line. ===Quoting escape=== When an escape character is needed within a string literal, there are two common strategies: Doubled delimiter For example, 'He didnt do it.' Secondary escape sequence For example, the command prompt command outputs "Cut&Paste" in by escaping the ampersand operator with a caret ( ^ ) In C and many related languages, the escape character is the backslash ( ). The single quotation mark character can be coded as '\ since is not valid. As a string literal is delimited by double-quotes ( " ) the content cannot contain a double-quote unless it is escaped ( "\"" ) or via a sequence that specifies the code of the double-quote character ( \x22 ). In Perl or Python 2, the following is invalid syntax: print "Nancy said "Hello World!" to the crowd." This can be fixed by inserted backslash to escape: print "Nancy said \"Hello World!\" to the crowd." Alternatively, the following uses "\x" to indicate the subsequent two characters are hexadecimal digits; "22" being the hexadecimal ASCII value for double-quote. print "Nancy said \x22Hello World!\x22 to the crowd." C, C++, Java, and Ruby allow the same two backslash escape styles. PostScript and rich text format (RTF) also use backslash escapes. The quoted-printable encoding uses the equals sign as an escape character. URL and URI use percent-encoding to quote characters with a special meaning, as for non-ASCII characters. ===ANSI escape sequences=== The VT52 terminal used simple digraph commands like escape-A. Without the escape character prefix, simply meant the letter , but as part of the escape sequence , it had a different meaning. The VT52 also supported parameters. It was not a straightforward control language encoded as substitution. The later VT100 terminal implemented the more sophisticated ANSI escape sequences standard (now ECMA-48) for functions such as controlling cursor movement, character set, and display enhancements. The 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. In Windows (and MS-DOS), a utility, ANSI.SYS, can be used to enable ANSI escape sequence support. In DOS via $e in the PROMPT command), and in 16-bit Windows via a command window. In Unix and Unix-like systems, the ANSI escape sequences are generally supported by the shell. The rise of GUI applications has reduced the use of escape sequences, yet the ability to provide full-screen, text-based applications is still available. ==Related== ===Control sequence=== A control sequence is a sequence of characters that changes the state of a computer peripheral instead of conveying the normal information that the characters represent. In an ANSI escape sequence, the escape sequence prefix, called control sequence introducer, can be either ASCII ESC (decimal 27) followed by [ or CSI (decimal 155). Notable systems that did not use an escape character for control sequences include: The Hayes command set defines a modal control sequence, +++ , which switches from command to online mode. To ensure that the sequence is interpreted as a control sequence instead of embedded in content, the sender stops communication for one second before and after sending . When the modem detects condition, it switches from normal mode (sending characters to the phone) to a command mode in which the data is interpreted a command. Sending the O command switches back to the normal mode. Data General terminal control sequences, but they often were still called escape sequences, and the very common use of "escaping" special characters in programming languages and command-line parameters today often use the "backslash" character to begin the sequence. Escape sequences in communications are commonly used when a computer and a peripheral have only a single channel through which to send information back and forth (so escape sequences are an example of in-band signaling). They were common when most dumb terminals used ASCII with 7 data bits for communication, and sometimes would be used to switch to a different character set for "foreign" or graphics characters that would otherwise been restricted by the 128 codes available in 7 data bits. Even relatively "dumb" terminals responded to some escape sequences, including the original mechanical Teletype printers (on which "glass Teletypes" or VDUs were based) responded to characters 27 and 31 to alternate between letters and figures modes. ===Esc key=== Many computer keyboards have an Esc key (where Esc is short for escape) even though it is generally not used for entering an escape sequence. The vi text editor uses the key to exit from input mode. Some application use the key to cancel an operation or navigate up a level of a nested context. ==See also== ==References==
References
- Escape Sequence (General Concept) · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Escape Sequence (General Concept)." 2026-11-18. https://www.spss-tutorials.com/escape-sequence/. Accessed 24 November 2026.
Chicago "Escape Sequence (General Concept)." 2026-11-18. https://www.spss-tutorials.com/escape-sequence/.
APA encyclopegia.org. (2026). Escape Sequence (General Concept). Retrieved November 24, 2026, from https://www.spss-tutorials.com/escape-sequence/
- ISO/IEC 9899:201x Committee Draft N1570 · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "ISO/IEC 9899:201x Committee Draft N1570." "ISO/IEC 9899:201x Committee Draft N1570" (PDF). 2026-11-18. http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf#page=29. Accessed 24 November 2026.
Chicago "ISO/IEC 9899:201x Committee Draft N1570." "ISO/IEC 9899:201x Committee Draft N1570" (PDF). 2026-11-18. http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf#page=29.
APA "ISO/IEC 9899:201x Committee Draft N1570" (PDF). (2026). ISO/IEC 9899:201x Committee Draft N1570. Retrieved November 24, 2026, from http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf#page=29
- 17. Understanding ANSI.SYS - Special Edition Using MS-DOS® 6.22, Third Edition [Book] · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "17. Understanding ANSI.SYS - Special Edition Using MS-DOS® 6.22, Third Edition [Book]." "17. 2026-11-18. https://www.oreilly.com/library/view/special-edition-using/0789725738/ch17.html. Accessed 24 November 2026.
Chicago "17. Understanding ANSI.SYS - Special Edition Using MS-DOS® 6.22, Third Edition [Book]." "17. 2026-11-18. https://www.oreilly.com/library/view/special-edition-using/0789725738/ch17.html.
APA "17. (2026). 17. Understanding ANSI.SYS - Special Edition Using MS-DOS® 6.22, Third Edition [Book]. Retrieved November 24, 2026, from https://www.oreilly.com/library/view/special-edition-using/0789725738/ch17.html
- Characters · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Characters." 2026-11-18. https://docs.oracle.com/javase/tutorial/java/data/characters.html. Accessed 24 November 2026.
Chicago "Characters." 2026-11-18. https://docs.oracle.com/javase/tutorial/java/data/characters.html.
APA encyclopegia.org. (2026). Characters. Retrieved November 24, 2026, from https://docs.oracle.com/javase/tutorial/java/data/characters.html
- Escape Sequences · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Escape Sequences." 2026-11-18. https://msdn.microsoft.com/en-us/library/h21280bw.aspx. Accessed 24 November 2026.
Chicago "Escape Sequences." 2026-11-18. https://msdn.microsoft.com/en-us/library/h21280bw.aspx.
APA encyclopegia.org. (2026). Escape Sequences. Retrieved November 24, 2026, from https://msdn.microsoft.com/en-us/library/h21280bw.aspx
- Escape sequences · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Escape sequences." 2026-11-18. https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.cbclx01/escape.htm. Accessed 24 November 2026.
Chicago "Escape sequences." 2026-11-18. https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.cbclx01/escape.htm.
APA encyclopegia.org. (2026). Escape sequences. Retrieved November 24, 2026, from https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.cbclx01/escape.htm
- Baudot and CCITT code · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Baudot and CCITT code." 2026-11-18. http://rabbit.eng.miami.edu/info/baudot.html. Accessed 24 November 2026.
Chicago "Baudot and CCITT code." 2026-11-18. http://rabbit.eng.miami.edu/info/baudot.html.
APA encyclopegia.org. (2026). Baudot and CCITT code. Retrieved November 24, 2026, from http://rabbit.eng.miami.edu/info/baudot.html
- AT Command Set and Register Summary for Analog Modem Modules · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "AT Command Set and Register Summary for Analog Modem Modules." 2026-11-18. https://www.cisco.com/c/en/us/td/docs/routers/access/2600/software/notes/analogat.html. Accessed 24 November 2026.
Chicago "AT Command Set and Register Summary for Analog Modem Modules." 2026-11-18. https://www.cisco.com/c/en/us/td/docs/routers/access/2600/software/notes/analogat.html.
APA encyclopegia.org. (2026). AT Command Set and Register Summary for Analog Modem Modules. Retrieved November 24, 2026, from https://www.cisco.com/c/en/us/td/docs/routers/access/2600/software/notes/analogat.html
- The Windows NT Command Shell · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "The Windows NT Command Shell." a b "The Windows NT Command Shell". 2026-11-18. https://technet.microsoft.com/en-us/library/cc723564.aspx. Accessed 24 November 2026.
Chicago "The Windows NT Command Shell." a b "The Windows NT Command Shell". 2026-11-18. https://technet.microsoft.com/en-us/library/cc723564.aspx.
APA a b "The Windows NT Command Shell". (2026). The Windows NT Command Shell. Retrieved November 24, 2026, from https://technet.microsoft.com/en-us/library/cc723564.aspx
- Data General DG210 DG211 Terminal Emulation Software · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Data General DG210 DG211 Terminal Emulation Software." 2026-11-18. https://www.hilgraeve.com/knowledge_base/dg210-dg211-emulation/. Accessed 24 November 2026.
Chicago "Data General DG210 DG211 Terminal Emulation Software." 2026-11-18. https://www.hilgraeve.com/knowledge_base/dg210-dg211-emulation/.
APA encyclopegia.org. (2026). Data General DG210 DG211 Terminal Emulation Software. Retrieved November 24, 2026, from https://www.hilgraeve.com/knowledge_base/dg210-dg211-emulation/
- Data General terminals: discussion of · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Data General terminals: discussion of." 2026-11-18. https://en.wikipedia.org/wiki/FTP. Accessed 24 November 2026.
Chicago "Data General terminals: discussion of." 2026-11-18. https://en.wikipedia.org/wiki/FTP.
APA encyclopegia.org. (2026). Data General terminals: discussion of. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/FTP
- Escape sequence · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Escape sequence." 2026-11-18. https://www6.dict.cc/wp_examples.php?lp_id=1%26lang=en%26s=escape%2520sequence. Accessed 24 November 2026.
Chicago "Escape sequence." 2026-11-18. https://www6.dict.cc/wp_examples.php?lp_id=1%26lang=en%26s=escape%2520sequence.
APA encyclopegia.org. (2026). Escape sequence. Retrieved November 24, 2026, from https://www6.dict.cc/wp_examples.php?lp_id=1%26lang=en%26s=escape%2520sequence
- What is ASCII? The Economist explains · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "What is ASCII? The Economist explains." 2026-11-18. https://www.economist.com/the-economist-explains/2013/06/09/what-is-ascii. Accessed 24 November 2026.
Chicago "What is ASCII? The Economist explains." 2026-11-18. https://www.economist.com/the-economist-explains/2013/06/09/what-is-ascii.
APA encyclopegia.org. (2026). What is ASCII? The Economist explains. Retrieved November 24, 2026, from https://www.economist.com/the-economist-explains/2013/06/09/what-is-ascii
- Chapter 5 – AT Commands · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Chapter 5 – AT Commands." "Chapter 5 – AT Commands" (PDF). 2026-11-18. https://www.perle.com/support_services/documentation_pdfs/5500158.pdf. Accessed 24 November 2026.
Chicago "Chapter 5 – AT Commands." "Chapter 5 – AT Commands" (PDF). 2026-11-18. https://www.perle.com/support_services/documentation_pdfs/5500158.pdf.
APA "Chapter 5 – AT Commands" (PDF). (2026). Chapter 5 – AT Commands. Retrieved November 24, 2026, from https://www.perle.com/support_services/documentation_pdfs/5500158.pdf
- Apostrophe Editing ('aaa') (FORTRAN 77 Language Reference) · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Apostrophe Editing ('aaa') (FORTRAN 77 Language Reference)." a b "Apostrophe Editing ('aaa') (FORTRAN 77 Language Reference)". 2026-11-18. https://docs.oracle.com/cd/E19957-01/805-4939/z40007438613/index.html. Accessed 24 November 2026.
Chicago "Apostrophe Editing ('aaa') (FORTRAN 77 Language Reference)." a b "Apostrophe Editing ('aaa') (FORTRAN 77 Language Reference)". 2026-11-18. https://docs.oracle.com/cd/E19957-01/805-4939/z40007438613/index.html.
APA a b "Apostrophe Editing ('aaa') (FORTRAN 77 Language Reference)". (2026). Apostrophe Editing ('aaa') (FORTRAN 77 Language Reference). Retrieved November 24, 2026, from https://docs.oracle.com/cd/E19957-01/805-4939/z40007438613/index.html
- What's a Terminal? · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "What's a Terminal?." 2026-11-18. https://www.kermitproject.org/terminals.html. Accessed 24 November 2026.
Chicago "What's a Terminal?." 2026-11-18. https://www.kermitproject.org/terminals.html.
APA encyclopegia.org. (2026). What's a Terminal?. Retrieved November 24, 2026, from https://www.kermitproject.org/terminals.html
- Basic Hayes AT Command Set · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Basic Hayes AT Command Set." 2026-11-18. http://www.modemhelp.net/basicatcommand.shtml. Accessed 24 November 2026.
Chicago "Basic Hayes AT Command Set." 2026-11-18. http://www.modemhelp.net/basicatcommand.shtml.
APA encyclopegia.org. (2026). Basic Hayes AT Command Set. Retrieved November 24, 2026, from http://www.modemhelp.net/basicatcommand.shtml
- Modem Programming Basics · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Modem Programming Basics." 2026-11-18. https://www.activexperts.com/serial-port-component/tutorials/modem. Accessed 24 November 2026.
Chicago "Modem Programming Basics." 2026-11-18. https://www.activexperts.com/serial-port-component/tutorials/modem.
APA encyclopegia.org. (2026). Modem Programming Basics. Retrieved November 24, 2026, from https://www.activexperts.com/serial-port-component/tutorials/modem
- Five Unexpected Uses for the Esc Key · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Five Unexpected Uses for the Esc Key." 2026-11-18. https://www.pcworld.com/article/174661/article.html. Accessed 24 November 2026.
Chicago "Five Unexpected Uses for the Esc Key." 2026-11-18. https://www.pcworld.com/article/174661/article.html.
APA encyclopegia.org. (2026). Five Unexpected Uses for the Esc Key. Retrieved November 24, 2026, from https://www.pcworld.com/article/174661/article.html
- Guide to the use of Character Sets in Europe · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Guide to the use of Character Sets in Europe." 2026-11-18. http://www.open-std.org/CEN/TC304/guidecharactersets/Annexa.doc. Accessed 24 November 2026.
Chicago "Guide to the use of Character Sets in Europe." 2026-11-18. http://www.open-std.org/CEN/TC304/guidecharactersets/Annexa.doc.
APA encyclopegia.org. (2026). Guide to the use of Character Sets in Europe. Retrieved November 24, 2026, from http://www.open-std.org/CEN/TC304/guidecharactersets/Annexa.doc
- Terminals & Printers Handbook Glossary · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Terminals & Printers Handbook Glossary." 2026-11-18. https://vt100.net/docs/tp83/glossary.html. Accessed 24 November 2026.
Chicago "Terminals & Printers Handbook Glossary." 2026-11-18. https://vt100.net/docs/tp83/glossary.html.
APA encyclopegia.org. (2026). Terminals & Printers Handbook Glossary. Retrieved November 24, 2026, from https://vt100.net/docs/tp83/glossary.html
- Twelve Useful · retrieved 2026-11-18 · rev 1366303812
Cite this reference
MLA "Twelve Useful." "Twelve Useful "vi" Commands". 2026-11-18. http://www.eng.buffalo.edu/~yearke/unix/vi12.shtml. Accessed 24 November 2026.
Chicago "Twelve Useful." "Twelve Useful "vi" Commands". 2026-11-18. http://www.eng.buffalo.edu/~yearke/unix/vi12.shtml.
APA "Twelve Useful "vi" Commands". (2026). Twelve Useful. Retrieved November 24, 2026, from http://www.eng.buffalo.edu/~yearke/unix/vi12.shtml
Cite this article
MLA
"Escape sequence." encyclopegia.org, 2026, https://encyclopegia.org/wiki/escape-sequence. Accessed 24 November 2026.
Chicago
"Escape sequence." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/escape-sequence.
APA
encyclopegia.org. (2026). Escape sequence. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/escape-sequence
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON