ArticleslgStudy

science

Escape character

Escape character is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Escape character rather than just read about it. In short: In computing and telecommunications, an escape character is a character (more specifically a metacharacter) that, based on a contextual convention, specifies an alternative interpretation of the sequence of characters that follow it. The escape character plus the characters that follow it to form a syntactic unit is called an escape sequence.

Key takeaways

  • Escape character belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Escape character to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Escape character from memory before moving on to harder problems.

Reference excerpt

In computing and telecommunications, an escape character is a character (more specifically a metacharacter) that, based on a contextual convention, specifies an alternative interpretation of the sequence of characters that follow it. The escape character plus the characters that follow it to form a syntactic unit is called an escape 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. In telecommunications, an escape character is used to indicate that the following characters are encoded differently. This is used to alter control characters that would otherwise be noticed and acted on by the underlying telecommunications hardware, such as illegal characters. In this context, the use of an escape character is sometimes referred to as quoting.

Definition An escape character may not have its own meaning, so all escape sequences are of two or more characters. Escape characters are part of the syntax for many programming languages, data formats, and communication protocols. For a given alphabet an escape character's purpose is to start character sequences (so named escape sequences), which have to be interpreted differently from the same characters occurring without the prefixed escape character. The functions of escape sequences include:

To encode a syntactic entity, such as device commands or special data, which cannot be directly represented by the alphabet. To represent characters, referred to as character quoting, which cannot be typed in the current context, or would have an undesired interpretation. In this case, an escape sequence is a digraph consisting of an escape character itself and a "quoted" character.

Control character In contrast to an escape character, a control character (i.e. carriage return) has meaning on its own, without a special prefix or following characters. An escape character has no meaning on its own. It only has meaning in the context of a sequence. Generally, an escape character is not a particular case of (device) control characters, nor vice versa. If we define control characters as non-graphic, or as having a special meaning for an output device (e.g. printer or text terminal) then any escape character for this device is a control one. But escape characters used in programming (such as the backslash, \) are graphic, hence are not control characters. Conversely most (but not all) of the ASCII "control characters" have some control function in isolation, therefore they are not escape characters. In many programming languages, an escape character also forms some escape sequences which are referred to as control characters. For example, line break has an escape sequence of \n.

Examples

JavaScript JavaScript uses the \ (backslash) as an escape character for:

\' single quote \" double quote \\ backslash \n new line \r carriage return \t tab \b backspace \f form feed \v vertical tab (Internet Explorer 9 and older treats \v as v instead of a vertical tab (\x0B). If cross-browser compatibility is a concern, use \x0B instead of \v.) \0 null character (U+0000 <control-0000> ) (only if the next character is not a decimal digit; else it is an octal escape sequence) \xFF character represented by the hexadecimal byte FF The \v and \0 escapes are not allowed in JSON strings.

Example code: A similar list is used by several other programming languages.

ASCII escape character The ASCII "escape" character (octal: \033, hexadecimal: \x1B, or, in decimal, 27, also represented by the sequences ^[ or \e) is used in many output devices to start a series of characters called a control sequence or escape sequence. Typically, the escape character was sent first in such a sequence to alert the device that the following characters were to be interpreted as a control sequence rather than as plain characters, then one or more characters would follow to specify some detailed action, after which the device would go back to interpreting characters normally. For example, the sequence of ^[, followed by the printable characters [2;10H, would cause a Digital Equipment Corporation (DEC) VT102 terminal to move its cursor to the 10th cell of the 2nd line of the screen. This was later developed into ANSI escape codes covered by the ANSI X3.64 standard. The escape character also starts each command sequence in the Hewlett-Packard Printer Command Language. An early reference to the term "escape character" is found in Bob Bemer's IBM technical publications, who is credited with inventing this mechanism during his work on the ASCII character set. The Escape key is usually found on standard PC keyboards. However, it is commonly absent from keyboards for PDAs and other devices not designed primarily for ASCII communications. The DEC VT220 series was one of the few popular keyboards that did not have a dedicated Esc key, instead of using one of the keys above the main keypad. In user interfaces of the 1970s–1980s it was not uncommon to use this key as an escape character, but in modern desktop computers, such use is dropped. Sometimes the key was identified with AltMode (for alternative mode). Even with no dedicated key, the escape character code could be generated by typing [ while simultaneously holding down Ctrl.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Escape character

Start with the simplest possible case. Write down what Escape character claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Escape character before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Escape character ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Escape character

In research
Escape character appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Escape character in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Escape character is common in secondary-school and first-year university syllabi. It links to neighbouring topics Control characters, Pattern matching, so understanding it makes those chapters shorter.
In everyday life
Look for Escape character outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Escape character” →

How to study Escape character in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Escape character means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Escape character out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Escape character in simple terms?

In computing and telecommunications, an escape character is a character (more specifically a metacharacter) that, based on a contextual convention, specifies an alternative interpretation of the sequence of characters that follow it. The escape character plus the characters that follow it to form a…

Why does Escape character matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Escape character?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Escape character.

Tags

  • Control characters
  • Pattern matching

Keep exploring