The Full Wiki

Escape character: Wikis

  

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Encyclopedia

From Wikipedia, the free encyclopedia

In computing and telecommunication, an escape character is a single character designated to invoke an alternative interpretation on immediately subsequent characters in a character sequence. The term escape sequence refers to the escape character and the character or characters whose meaning is modified.

Contents

Examples

Programming languages

Many modern programming languages specify the doublequote character (") as a delimiter for a string literal. 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 Perl:

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++, and Java (programming language) all allow exactly the same two backslash escape styles, while quoted-printable 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).

Bourne shell

In Bourne shell (sh), the asterisk character (*) is a wildcard character expanded via globbing. Without a preceding escape character, it will expand to the names of all files in the working directory 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 *

Windows Command Prompt

The Windows command-line interpreter uses a caret character (^) to escape reserved characters that have special meanings (in particular: & | ( ) < > ^).[1] The DOS command-line interpreter, though it supports similar syntax, does not support this.

For example, on the Windows Command Prompt, this will result in a syntax error.

echo <wiki>

whereas this will output the string: <wiki>

echo ^<wiki^>

Categories

  • In alphabet coding schemes, a specially designated character, the occurrence of which in the data signifies that one or more of the characters to follow are from a different character code, i.e., have meanings other than normal.
  • In a text-control sequence of characters, a control character 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 sequence).
  • In the ASCII character code, the character ESC with decimal code 27 and hexadecimal code 1B.

Early reference to this term is found in Bob Bemer'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.

References

  1. ^ Tim Hill (1998). "The Windows NT Command Shell". MacMillan Technical Publishing. http://technet.microsoft.com/en-us/library/cc723564.aspx. Retrieved 2010-01-13.  

See also

External links

PD-icon.svg This article incorporates public domain material from the General Services Administration document "Federal Standard 1037C".








Got something to say? Make a comment.
Your name
Your email address
Message