In
computingComputing is usually defined as the activity of using and developing computer technology, computer hardware and software. It is the computer-specific part of information technology...
and
telecommunicationTelecommunication is transmission over a distance for the purpose of communication. In earlier times, this may have involved the use of smoke signals, drums, semaphore, flags or heliograph. In modern times, telecommunication typically involves the use of electronic devices such as the telephone,...
, an
escape character is a single character designated to invoke an alternative interpretation on immediately subsequent characters in a character sequence. The term
escape sequenceAn 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 which always have the same meaning...
refers to the escape character and the character or characters whose meaning is modified.
Many modern
programming languageA programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine, to express algorithms precisely, or as a mode of human...
s specify the doublequote character (") as a
delimiterA delimiter is a sequence of one or more characters used to specify the boundary between separate, independent regions in plain text or other data streams. An example of a delimiter is the comma character, which acts as a field delimiter in a sequence of comma-separated values.Delimiters represent...
for a
string literalA string literal is the representation of a string value within the source code of a computer program. There are numerous alternate notations for specifying string literals, and the exact notation depends on the individual programming language in question...
. The backslash \ escape character provides two ways to include doublequotes inside a string literal, either by modifying the meaning of the doublequote character embedded in the string (\" becomes "), or by modifying the meaning of the three characters that are the hexadecimal value of a doublequote character (\x22 becomes ").
In
PerlPerl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall, a linguist working as a systems administrator for NASA, in 1987, as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone...
:
-
print "Nancy said "Hello World!" to the crowd.";
produces a syntax error, whereas:
-
print "Nancy said \"Hello World!\" to the crowd."; ### example of \"
produces the intended output.
Another alternative:
-
print "Nancy said \x22Hello World!\x22 to them."; ### example of \x22
uses numeric escape-sequence of hexadecimal "x22" for a quotemark.
C (programming language)C is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
,
C++C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features...
, and
Java (programming language)Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
all allow exactly the same two backslash escape styles, while
quoted-printableQuoted-printable, or QP encoding, is an encoding using printable characters to transmit 8-bit data over a 7-bit data path. It is defined as a MIME content transfer encoding for use in Internet e-mail....
uses a slightly different numeric escape sequence.
Some programming languages also provide other ways to prevent this type of error, without requiring an escape character (see e.g.
In
computingComputing is usually defined as the activity of using and developing computer technology, computer hardware and software. It is the computer-specific part of information technology...
and
telecommunicationTelecommunication is transmission over a distance for the purpose of communication. In earlier times, this may have involved the use of smoke signals, drums, semaphore, flags or heliograph. In modern times, telecommunication typically involves the use of electronic devices such as the telephone,...
, an
escape character is a single character designated to invoke an alternative interpretation on immediately subsequent characters in a character sequence. The term
escape sequenceAn 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 which always have the same meaning...
refers to the escape character and the character or characters whose meaning is modified.
Programming languages
Many modern
programming languageA programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine, to express algorithms precisely, or as a mode of human...
s specify the doublequote character (") as a
delimiterA delimiter is a sequence of one or more characters used to specify the boundary between separate, independent regions in plain text or other data streams. An example of a delimiter is the comma character, which acts as a field delimiter in a sequence of comma-separated values.Delimiters represent...
for a
string literalA string literal is the representation of a string value within the source code of a computer program. There are numerous alternate notations for specifying string literals, and the exact notation depends on the individual programming language in question...
. The backslash \ escape character provides two ways to include doublequotes inside a string literal, either by modifying the meaning of the doublequote character embedded in the string (\" becomes "), or by modifying the meaning of the three characters that are the hexadecimal value of a doublequote character (\x22 becomes ").
In
PerlPerl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall, a linguist working as a systems administrator for NASA, in 1987, as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone...
:
-
print "Nancy said "Hello World!" to the crowd.";
produces a syntax error, whereas:
-
print "Nancy said \"Hello World!\" to the crowd."; ### example of \"
produces the intended output.
Another alternative:
-
print "Nancy said \x22Hello World!\x22 to them."; ### example of \x22
uses numeric escape-sequence of hexadecimal "x22" for a quotemark.
C (programming language)C is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
,
C++C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features...
, and
Java (programming language)Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
all allow exactly the same two backslash escape styles, while
quoted-printableQuoted-printable, or QP encoding, is an encoding using printable characters to transmit 8-bit data over a 7-bit data path. It is defined as a MIME content transfer encoding for use in Internet e-mail....
uses a slightly different numeric escape sequence.
Some programming languages also provide other ways to prevent this type of error, without requiring an escape character (see e.g. delimiter collision).
In the Bourne shell
In
shThe Bourne shell, or sh, was the default Unix shell of Unix Version 7, and replaced the Thompson shell, whose executable file had the same name, sh. It was developed by Stephen Bourne, of AT&T Bell Laboratories, and was released in 1977 in the Version 7 Unix release distributed to colleges and...
, the * character is a
wildcard character-Telecommunication:In telecommunications, a wildcard character is a character that may be substituted for any of a defined subset of all possible characters....
expanded via globbing. Without a preceding escape character, it will expand to the names of all files in the
working directoryIn computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. When the process refers to a file using a simple file name or relative path , the reference is interpreted relative to the current working directory of...
that don't start with a period if and only if there are such files, otherwise * remains unexpanded. So to refer to a file literally called "*", the shell must be told not to interpret it in this way, by preceding it with a backslash ("\"). This modifies the interpretation of the asterisk ("*"). Compare:
| |
rm * # delete all files in the current directory
rm \* # delete the file named *
|
Categories
- In alphabet
An alphabet is a standardized set of letters basic written symbols or graphemes each of which roughly represents a phoneme in a spoken language, either as it exists now or as it was in the past. There are other systems, such as logographies, in which each character represents a word, morpheme, or...
codingCoding may refer to:* Coding theory* Computer programming* The process of Statistical classification of information*coding *legal coding* A coding strand of DNA is translated into a protein product...
schemes, a specially designated characterIn computer and machine-based telecommunications terminology, a character is a unit of information that roughly corresponds to a grapheme, grapheme-like unit, or symbol, such as in an alphabet or syllabary in the written form of a natural language....
, the occurrence of which in the dataThe term data means groups of information that represent the qualitative or quantitative attributes of a variable or set of variables. Data are typically the results of measurements and can be the basis of graphs, images, or observations of a set of variables...
signifies that one or more of the characters to follow are from a different character codeIn communications, a code is a rule for converting a piece of information into another form or representation , not necessarily of the same type. In communications and information processing, encoding is the process by which information from a source is converted into symbols to be communicated...
, i.e., have meanings other than normal.
- In a text-control sequence
In mathematics, a sequence is an ordered list of objects . Like a set, it contains members , and the number of terms is called the length of the sequence...
of characters, a control characterIn computing and telecommunication, a control character or non-printing character is a code point in a character set, that does not in itself represent a written symbol.It is in-band signaling in the context of character encoding....
that indicates the beginning of the sequence and the end of any preceding text. This is for instance used to control text terminals and printers (see escape sequenceAn 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 which always have the same meaning...
).
- In the ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...
character code, the character ESC with decimalThe decimal numeral system has ten as its base. It is the most widely used numeral base.- Decimal notation :...
code 27 and hexadecimalIn mathematics and computer science, hexadecimal is a numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen.Its primary use is as a...
code 1B.
Early reference to this term is found in
Bob BemerRobert William Bemer was a computer scientist best known for his work at IBM during the late 1950s and early 1960s.-Biography:...
's IBM technical publications.
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, and not generally used as part of the common user interface for applications on the Windows operating system. The DEC VT220 series was one of the few popular keyboards that did not have a dedicated Esc key, instead using one of the keys above the main keypad.
See also
- Esc key
On computer keyboards, the Esc key is a key labeled Esc or Escape that is used to generate the ASCII Escape character , the character code traditionally used to initiate an escape sequence....
- Escape sequence
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 which always have the same meaning...
- ANSI escape code
ANSI escape sequences are used to control text formatting and other output options on text terminals. In this context, ANSI refers to the ANSI X3.64 standard...
- Delimiter
A delimiter is a sequence of one or more characters used to specify the boundary between separate, independent regions in plain text or other data streams. An example of a delimiter is the comma character, which acts as a field delimiter in a sequence of comma-separated values.Delimiters represent...
- Metacharacter
A metacharacter is a character that has a special meaning to a computer program, such as a shell interpreter or a regular expression engine.- Examples :...
- Stropping
When applied to computer languages, stropping refers to the method used to mark letter sequences as having a special property...
External links