Backslash
Encyclopedia
The backslash is a typographical mark (glyph
) used mainly in computing
. It was first introduced to computers in 1960 by Bob Bemer
. Sometimes called a reverse solidus or a slosh, it is the mirror image of the common slash
.
Other common terms for the character include hack, escape
(from C
/UNIX
), reverse slash, backslant, and backwhack. Also, it is sometimes referred as bash, reverse slant, reversed virgule, or backslat.
introduced the "\" character into ASCII, on September 18, 1961, as the result of character frequency studies. In particular the \ was introduced so that the ALGOL boolean operators ∧
(AND) and ∨
(OR) could be composed in ASCII as "/\" and "\/" respectively. Both these operators were included in early versions of the C programming language supplied with Unix V6 , Unix V7 and more currently BSD 2.11.
In many programming language
s such as C
and Perl
and in Unix
scripting languages, the backslash is used to indicate that the character following it should be treated specially (if it would otherwise be treated normally), or normally (if it would otherwise be treated specially). It is sometimes referred to as a knock-down or escape character
. In various regular expression
languages it acts as a switch, changing literal characters into metacharacter
s and vice versa. The backslash is used similarly in the TeX
typesetting
system and in RTF
files to begin markup tags. In Haskell
, the backslash is used both to introduce special characters and to introduce lambda functions
(since it is a reasonable approximation in ASCII of the Greek letter lambda, λ).
In the context of line-oriented text, especially source code
for some programming language
s, it is often used at the end of a line to indicate that the trailing newline
character should be ignored, so that the following line is treated as if it were part of the current line. In this context it may be called a "continuation". The GNU make manual says, "We split each long line into two lines using backslash-newline; this is like using one long line, but is easier to read."
The Windows API
can accept either the backslash or slash to separate directory and file components of a path
, but the Microsoft convention is to use a backslash, and APIs that return paths put backslash in. MS-DOS
2.0, released 1983, copied the hierarchical file system from Unix and thus used the forward slash, but (possibly on the insistence of IBM) added the backslash to allow paths to be typed into the command shell while retaining compatibility with MS-DOS 1.0 and CP/M
where the slash was the command-line option indicator (i.e. as in typing "dir/w" to give the "wide" option to the "dir" command). Although the command shell was the only part of MS-DOS that required this, the use of backslash in filenames was propagated to most other parts of the user interface. Today, although the underlying operating system supports either character, many Windows programs and sub-systems do not accept the slash as a path delimiter or may misinterpret it if it is used as such. Some programs will only accept forward slashes if the path is placed in double-quotes
. Failures of Microsoft security features to recognize unexpected-direction slashes in local and internet paths, while other parts of the operating system still act upon them, have led to some serious lapses in security. Resources that should not be available have been accessed with paths using particular mixes, such as
In the Japanese
encodings ISO 646 (a 7-bit code based on ASCII
), JIS X 0201
(an 8-bit code) and Shift JIS (a multi-byte encoding which is 8-bit for ASCII) the code point
0x5C that would be used for backslash in ASCII is instead rendered as a yen mark
(¥), while in Korean
encoding, it is drawn as a won currency symbol (₩). Computer programs still treat the code as a backslash in these environments, causing confusion, especially in MSDOS filenames. Due to extensive use of the backslash code to represent the yen mark, even today some Unicode fonts like MS Mincho render the backslash character as a ¥, so the Unicode
characters 00A5 (¥) and 005C (\) look identical when these fonts are selected. Several other ISO 646 versions also replace backslash with characters like Ö (German, Swedish), Ø (Danish, Norwegian), ç (French) and Ñ (Spanish), though this seems to not have caused such widespread problems.
In mathematics
, a backslash-like symbol is used for the set difference
.
In some dialects of the BASIC
programming language, the backslash is used as an operator symbol to indicate integer
division
.
In MATLAB
and GNU Octave
the backslash is used for left matrix divide, while the slash is for right matrix divide.
Glyph
A glyph is an element of writing: an individual mark on a written medium that contributes to the meaning of what is written. A glyph is made up of one or more graphemes....
) used mainly in computing
Computing
Computing is usually defined as the activity of using and improving computer hardware and software. It is the computer-specific part of information technology...
. It was first introduced to computers in 1960 by Bob Bemer
Bob Bemer
Robert William Bemer was a computer scientist best known for his work at IBM during the late 1950s and early 1960s.-Biography:...
. Sometimes called a reverse solidus or a slosh, it is the mirror image of the common slash
Slash (punctuation)
The slash is a sign used as a punctuation mark and for various other purposes. It is now often called a forward slash , and many other alternative names.-History:...
.
Other common terms for the character include hack, escape
Escape character
In computing and telecommunication, an escape character is a character which invokes an alternative interpretation on subsequent characters in a character sequence. An escape character is a particular case of metacharacters...
(from C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
/UNIX
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...
), reverse slash, backslant, and backwhack. Also, it is sometimes referred as bash, reverse slant, reversed virgule, or backslat.
Usage
Bob BemerBob Bemer
Robert William Bemer was a computer scientist best known for his work at IBM during the late 1950s and early 1960s.-Biography:...
introduced the "\" character into ASCII, on September 18, 1961, as the result of character frequency studies. In particular the \ was introduced so that the ALGOL boolean operators ∧
Logical conjunction
In logic and mathematics, a two-place logical operator and, also known as logical conjunction, results in true if both of its operands are true, otherwise the value of false....
(AND) and ∨
Logical disjunction
In logic and mathematics, a two-place logical connective or, is a logical disjunction, also known as inclusive disjunction or alternation, that results in true whenever one or more of its operands are true. E.g. in this context, "A or B" is true if A is true, or if B is true, or if both A and B are...
(OR) could be composed in ASCII as "/\" and "\/" respectively. Both these operators were included in early versions of the C programming language supplied with Unix V6 , Unix V7 and more currently BSD 2.11.
In many programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
s such as C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
and Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...
and in Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...
scripting languages, the backslash is used to indicate that the character following it should be treated specially (if it would otherwise be treated normally), or normally (if it would otherwise be treated specially). It is sometimes referred to as a knock-down or escape character
Escape character
In computing and telecommunication, an escape character is a character which invokes an alternative interpretation on subsequent characters in a character sequence. An escape character is a particular case of metacharacters...
. In various regular expression
Regular expression
In computing, a regular expression provides a concise and flexible means for "matching" strings of text, such as particular characters, words, or patterns of characters. Abbreviations for "regular expression" include "regex" and "regexp"...
languages it acts as a switch, changing literal characters into metacharacter
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:...
s and vice versa. The backslash is used similarly in the TeX
TeX
TeX is a typesetting system designed and mostly written by Donald Knuth and released in 1978. Within the typesetting system, its name is formatted as ....
typesetting
Typesetting
Typesetting is the composition of text by means of types.Typesetting requires the prior process of designing a font and storing it in some manner...
system and in RTF
Rich Text Format
The Rich Text Format is a proprietary document file format with published specification developed by Microsoft Corporation since 1987 for Microsoft products and for cross-platform document interchange....
files to begin markup tags. In Haskell
Haskell (programming language)
Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry. In Haskell, "a function is a first-class citizen" of the programming language. As a functional programming language, the...
, the backslash is used both to introduce special characters and to introduce lambda functions
Anonymous function
In programming language theory, an anonymous function is a function defined, and possibly called, without being bound to an identifier. Anonymous functions are convenient to pass as an argument to a higher-order function and are ubiquitous in languages with first-class functions such as Haskell...
(since it is a reasonable approximation in ASCII of the Greek letter lambda, λ).
In the context of line-oriented text, especially source code
Source code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...
for some programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
s, it is often used at the end of a line to indicate that the trailing newline
Newline
In computing, a newline, also known as a line break or end-of-line marker, is a special character or sequence of characters signifying the end of a line of text. The name comes from the fact that the next character after the newline will appear on a new line—that is, on the next line below the...
character should be ignored, so that the following line is treated as if it were part of the current line. In this context it may be called a "continuation". The GNU make manual says, "We split each long line into two lines using backslash-newline; this is like using one long line, but is easier to read."
The Windows API
Windows API
The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces available in the Microsoft Windows operating systems. It was formerly called the Win32 API; however, the name "Windows API" more accurately reflects its roots in 16-bit Windows and its support on...
can accept either the backslash or slash to separate directory and file components of a path
Path (computing)
A path, the general form of a filename or of a directory name, specifies a unique location in a file system. A path points to a file system location by following the directory tree hierarchy expressed in a string of characters in which path components, separated by a delimiting character, represent...
, but the Microsoft convention is to use a backslash, and APIs that return paths put backslash in. MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...
2.0, released 1983, copied the hierarchical file system from Unix and thus used the forward slash, but (possibly on the insistence of IBM) added the backslash to allow paths to be typed into the command shell while retaining compatibility with MS-DOS 1.0 and CP/M
CP/M
CP/M was a mass-market operating system created for Intel 8080/85 based microcomputers by Gary Kildall of Digital Research, Inc...
where the slash was the command-line option indicator (i.e. as in typing "dir/w" to give the "wide" option to the "dir" command). Although the command shell was the only part of MS-DOS that required this, the use of backslash in filenames was propagated to most other parts of the user interface. Today, although the underlying operating system supports either character, many Windows programs and sub-systems do not accept the slash as a path delimiter or may misinterpret it if it is used as such. Some programs will only accept forward slashes if the path is placed in double-quotes
Quotation mark
Quotation marks or inverted commas are punctuation marks at the beginning and end of a quotation, direct speech, literal title or name. Quotation marks can also be used to indicate a different meaning of a word or phrase than the one typically associated with it and are often used to express irony...
. Failures of Microsoft security features to recognize unexpected-direction slashes in local and internet paths, while other parts of the operating system still act upon them, have led to some serious lapses in security. Resources that should not be available have been accessed with paths using particular mixes, such as
http://example.net/secure\private.aspx
.In the Japanese
Japanese language
is a language spoken by over 130 million people in Japan and in Japanese emigrant communities. It is a member of the Japonic language family, which has a number of proposed relationships with other languages, none of which has gained wide acceptance among historical linguists .Japanese is an...
encodings ISO 646 (a 7-bit code based on ASCII
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...
), JIS X 0201
JIS X 0201
JIS X 0201, a Japanese Industrial Standard developed in 1969 , was the first Japanese character set to become widely used. It is either 7-bit encoding or 8-bit encoding, although 8-bit encoding is dominant for modern use...
(an 8-bit code) and Shift JIS (a multi-byte encoding which is 8-bit for ASCII) the code point
Code point
In character encoding terminology, a code point or code position is any of the numerical values that make up the code space . For example, ASCII comprises 128 code points in the range 0hex to 7Fhex, Extended ASCII comprises 256 code points in the range 0hex to FFhex, and Unicode comprises 1,114,112...
0x5C that would be used for backslash in ASCII is instead rendered as a yen mark
¥
¥ is a currency sign used by the Japanese yen and the Chinese yuan currencies. The symbol resembles a Latin letter Y with a double stroke. The base unit of both currencies shared the same Chinese character pronounced yuán in Mandarin Chinese and en in Standard Japanese...
(¥), while in Korean
Korean language
Korean is the official language of the country Korea, in both South and North. It is also one of the two official languages in the Yanbian Korean Autonomous Prefecture in People's Republic of China. There are about 78 million Korean speakers worldwide. In the 15th century, a national writing...
encoding, it is drawn as a won currency symbol (₩). Computer programs still treat the code as a backslash in these environments, causing confusion, especially in MSDOS filenames. Due to extensive use of the backslash code to represent the yen mark, even today some Unicode fonts like MS Mincho render the backslash character as a ¥, so the Unicode
Unicode
Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems...
characters 00A5 (¥) and 005C (\) look identical when these fonts are selected. Several other ISO 646 versions also replace backslash with characters like Ö (German, Swedish), Ø (Danish, Norwegian), ç (French) and Ñ (Spanish), though this seems to not have caused such widespread problems.
In mathematics
Mathematics
Mathematics is the study of quantity, space, structure, and change. Mathematicians seek out patterns and formulate new conjectures. Mathematicians resolve the truth or falsity of conjectures by mathematical proofs, which are arguments sufficient to convince other mathematicians of their validity...
, a backslash-like symbol is used for the set difference
Complement (set theory)
In set theory, a complement of a set A refers to things not in , A. The relative complement of A with respect to a set B, is the set of elements in B but not in A...
.
In some dialects of the BASIC
BASIC
BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use - the name is an acronym from Beginner's All-purpose Symbolic Instruction Code....
programming language, the backslash is used as an operator symbol to indicate integer
Integer (computer science)
In computer science, an integer is a datum of integral data type, a data type which represents some finite subset of the mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values....
division
Division (mathematics)
right|thumb|200px|20 \div 4=5In mathematics, especially in elementary arithmetic, division is an arithmetic operation.Specifically, if c times b equals a, written:c \times b = a\,...
.
In MATLAB
MATLAB
MATLAB is a numerical computing environment and fourth-generation programming language. Developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages,...
and GNU Octave
GNU Octave
GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command-line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with MATLAB...
the backslash is used for left matrix divide, while the slash is for right matrix divide.
External links
- Larry Osterman (2005-06-24), Why is the DOS path character "\"?
- Bob Bemer, How ASCII got its backslash
- Backslash Definition by The Linux Information Project (LINFO)