|In Unicode||U+005C \ REVERSE SOLIDUS (\)|
|See also||U+29F5 ⧵ REVERSE SOLIDUS OPERATOR|
U+29F9 ⧹ BIG REVERSE SOLIDUS
As of November 2021[update], efforts to identify either the origin of this character or its purpose before the 1960s have not been successful. The earliest known reference found to date is a 1937 maintenance manual from the Teletype Corporation with a photograph showing the keyboard of its Kleinschmidt keyboard perforator WPE-3 using the Wheatstone system. The symbol was called the "diagonal key", and given a (non-standard) Morse code of ▄ ▄▄▄ ▄ ▄ ▄▄▄ . (This is the code for the slash symbol, entered backwards.)
In June 1960, IBM published an "Extended character set standard" that includes the symbol at 0x19. In September 1961, Bob Bemer (IBM) proposed to the X3.2 standards committee that
\ be made part of the proposed standard, describing the backslash as a "reverse division operator" and cited its prior use by Teletype in telecommunications. In particular, he said, the \ was needed so that the ALGOL boolean operators
∧ (logical conjunction) and
∨ (logical disjunction) could be composed using /\ and \/ respectively. The Committee adopted these changes into the draft American Standard (subsequently called ASCII) at its November 1961 meeting.
The Teletype Model 33 (1963) appears to be the first commercially available unit that has the character as a standard keytop for sale in some markets; this model has a full ASCII character set.
In many programming languages such as C, Perl, PHP, Python, Unix scripting languages, and many file formats such as JSON, the backslash is used as an escape character, to indicate that the character following it should be treated specially (if it would otherwise be treated literally), or literally (if it would otherwise be treated specially). For instance, inside a C string literal the sequence
\n produces a newline byte instead of an 'n', and the sequence
\" produces an actual double quote rather than the special meaning of the double quote ending the string. An actual backslash is produced by a double backslash
Regular expression languages used it the same way, changing subsequent literal characters into metacharacters and vice versa. For instance \||b searches for either '|' or 'b', the first bar is escaped and searched for, the second is not escaped and acts as an "or".
Outside quoted strings, the only common use of backslash is to ignore ("escape") a newline immediately after it. In this context it may be called a "continued line" as the current line continues into the next one. Some software replaces the backslash+newline with a space.
To support computers that lacked the backslash character, the C trigraph
??/ was added, which is equivalent to a backslash. Since this can escape the next character, which may itself be a
?, the primary modern use may be for code obfuscation. Support for trigraphs in C++ was removed in C++17, though it remains in C.
The ALGOL 68 programming language uses the "\" as its Decimal Exponent Symbol. ALGOL 68 has the choice of 4 Decimal Exponent Symbols: e, E, \, or 10. Examples: 6.0221415e23, 6.0221415E23, 6.0221415\23 or 6.02214151023.
In APL \ is called Expand when used to insert fill elements into arrays, and Scan when used to produce prefix reduction (cumulative fold).
MS-DOS 2.0, released 1983, copied the hierarchical file system from Unix and thus used the (forward) slash as the directory separator. Possibly on the insistence of IBM, Microsoft added the backslash to allow paths to be typed at the command line interpreter prompt, while retaining compatibility with MS-DOS 1.0 (in which was the command-line option indicator. Typing "DIR/W" gave the "wide" option to the "DIR" command, so some other method was needed if one actually wanted to run a program called W inside a directory called DIR). Except for COMMAND.COM, all other parts of the operating system accept both characters in a path, but the Microsoft convention remains to use a backslash, and APIs that return paths use backslashes. In some versions, the option character can be changed from / to - via SWITCHAR, which allows COMMAND.COM to preserve / in the command name.
The Microsoft Windows family of operating systems inherited the MS-DOS behavior and so still support either character – but individual Windows programs and sub-systems may, wrongly, only accept the backslash as a path delimiter, or may misinterpret a forward slash if it is used as such. Some programs will only accept forward slashes if the path is placed in double-quotes. The failure of Microsoft's security features to recognize unexpected-direction slashes in local and Internet paths, while other parts of the operating system still act upon them, has 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.
Especially when describing computer algorithms, it is common to define backslash so that a\b is equivalent to ⌊a/b⌋. This is integer division that rounds down, not towards zero. In Wolfram Mathematica the backslash is used this way for integer divide.
Confusion with ¥ and other charactersEdit
In the Japanese encodings ISO 646-JP (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 sign . Due to extensive use of the 005C code point to represent the yen sign, even today some fonts such as MS Mincho render the backslash character as a ¥, so the characters at Unicode code points 00A5 (¥) and 005C (\) both render as when these fonts are selected. Computer programs still treat 005C as a backslash in these environments but display it as a yen sign, causing confusion, especially in MS-DOS filenames.
Several other ISO 646 versions also replace backslash with other characters, including ₩ (Korean), Ö (German, Swedish), Ø (Danish, Norwegian), ç (French) and Ñ (Spanish), leading to similar problems, though with less lasting impact compared to the yen sign.
In 1991, RFC 1345 suggested
// as a unique two-character mnemonic that might be used in internet standards as "a practical way of identifying [this] character, without reference to a coded character set and its code in [that] coded character set". Consequently, this style may be seen in early Internet Engineering Task Force documents.
- Slash (or 'solidus'),
- Bulletin 125, issue 2: Description and Adjustments of the Teletype Wheatstone Perforator (PDF). Teletype Corporation. May 1938 [August 1937]. p. ii – via navy-radio.com.
- Fischer, Eric (20 June 2000). "The Evolution of Character Codes, 1874–1968". pp. 14 (Table 35), 15. CiteSeerX 10.1.1.96.678. (unpublished paper submitted to IEEE, better source needed.)
- Bulletin 188: Teletype automatic perforator set (PDF). Teletype Corporation. August 1945 – via navy-radio.com.
- Bulletin 1025, issue 3: Parts for Teletype Wheatstone Perforator (PDF). Teletype Corporation. July 1945 – via navy-radio.com.
- "C compiler source". bitsavers.org. 1975.
- "C compiler source". mit.edu. 1979.
- "The C Preprocessor". gnu.org.
- "3.1.1 Splitting long lines". GNU make manual. Retrieved July 28, 2019.
- "Arithmetic Operators in Visual Basic". Visual Basic Language Features: Operators and Expressions. MSDN. Retrieved 7 October 2012.
- "Revised Report on the Algorithmic Language Algol 68". Acta Informatica. 5 (1–3): 1–236. September 1973. doi:10.1007/BF00265077. S2CID 2490556.
- "Namespaces overview". php.net.
- O'Sullivan, Stewart, and Goerzen, Real World Haskell, ch. 4: anonymous (lambda) functions, p.99
- "Why is the DOS path character "\"?". Blogs.msdn.com. 2005-06-24. Retrieved 2013-06-16.
- Necasek, Michal (24 May 2019). "Why Does Windows Really Use Backslash as Path Separator?". OS/2 Museum. Archived from the original on 24 May 2019. Retrieved 28 May 2019.
- Larson, Chris; Immerwahr, Don (1983), MS-DOS v1.25 and v2.0 Source Code, README.txt, Microsoft, retrieved 21 November 2022,
The user manual contains some significant errors. Most of these are due to last minute changes to achieve a greater degree of compatibility with IBM's implementation of MS-DOS (PC DOS). This includes the use of "\" instead of "/" as the path separator, and "/" instead of "-" as the switch character. For transporting of batch files across machines, Microsoft encourages the use of "\" and "/" respectively in the U.S. market. [...] We apologize for any inconveniences these changes may have caused your technical publications staff.
- "Path.GetFullPath Method". .NET Framework Class Library. Microsoft. Archived from the original on 21 December 2008. Retrieved 2009-01-02.
- "When did Windows start accepting forward slash as a path separator?". Bytes.com. Archived from the original on 6 February 2009. Retrieved 2009-01-02.
- Kaplan, Simone (2004). "Microsoft Probes Flaw in ASP.NET". DevSource, sponsored by Microsoft. Ziff Davis Enterprise Holdings Inc. Archived from the original on 2013-01-21. Retrieved 2009-06-14.
- Burnett, Mark (2004). "Security Holes That Run Deep". SecurityFocus. Retrieved 2009-06-14.
- "USFM – Unified Standard Format Markers". paratext.org. 18 April 2017.
- "C0 control characters set, 1987". pd.infn.it.
- "Quantities and units – Part 2: Mathematical signs and symbols to be used in the natural sciences and technology". ISO 80000-2:2009. International Organization for Standardization.
- "Definition:Coset Space". ProofWiki. Retrieved 1 February 2017.
- "Integer Division". mathworld.wolfram.com.
- Eaton, John W.; David Bateman; Søren Hauberg (February 2011). "GNU Octave: A high-level interactive language for numerical computations" (PDF). Free Software Foundation. p. 145. Retrieved 7 October 2012.
- "When is a backslash not a backslash?". Blogs.msdn.com. Retrieved 2013-06-16.
- Simonsen, Keld (1991-12-26). "RFC 1345". Tools.ietf.org. Retrieved 2013-06-16.