Backslash escapes

From Just Solve the File Format Problem
Revision as of 15:42, 1 July 2019 by Dan Tobias (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
File Format
Name Backslash escapes
Wikidata ID Q1366300, Q17077094

Backslash escapes are one of the methods various programming, scripting, and markup languages use to allow the inclusion of characters in text strings that might otherwise be difficult or impossible to use, because they have special syntactic meaning, are not part of the currently-used character set, are difficult to type, or are nonprinting characters that don't show in a display. These were introduced in the C programming language, but some version of them is in use in a number of other languages and formats.

These are the standard C backspace escapes:

Escape sequence Meaning
\a Alert/beep/bell (BEL, 07)
\b Backspace (BS, 08)
\f Formfeed (FF, 0C)
\n Newline/Linefeed (LF, 0A)
\r Carriage Return (CR, 0D)
\t Horizontal Tab (HT, 09)
\v Vertical Tab (VT, 0B)
\\ Backslash (\, 5C)
\' Apostrophe/single-quote (', 27)
\" Double quote (", 22)
\? Question mark (?, 3F)
\nnn Byte specified as octal number
\xhh Byte specified as hexadecimal number
\uhhhh Unicode character (range 0000-FFFF)
\Uhhhhhhhh Unicode character (full range)

Some additions and variations may be used in different systems. Often \e stands for the escape character (ESC, 1B), though this is not one of the official standard C escapes. The newline (\n) might get translated to a system-specific line break sequence such as CR or CR+LF. Various other characters that have syntactic meanings in programming languages or regular-expression parsers, like forward slashes, semicolons, and asterisks, are often prefixed with backslashes when used as literals.


Personal tools