Backslash Explained
The backslash is a mark used mainly in computing and mathematics. It is the mirror image of the common slash . It is a relatively recent mark, first documented in the 1930s. It is sometimes called a hack, whack, escape (from C/UNIX), reverse slash, slosh, downwhack, backslant, backwhack, bash, reverse slant, reverse solidus, and reversed virgule.[1] [2]
History
, 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",[3] and given a (non-standard) Morse code of .[4]
In June 1960, IBM published an "Extended character set standard" that includes the symbol at 0x19.[5] In September 1961, Bob Bemer (IBM) proposed to the X3.2 standards committee that, and 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.
These operators were used for min and max in early versions of the C programming language supplied with Unix V6[6] and V7.[7]
Usage
Programming languages
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 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 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"[8] as the current line continues into the next one. Some software replaces the backslash+newline with a space.[9]
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, and support for them in C is planned to be removed in C23.
In Visual Basic (and some other BASIC dialects) the backslash is used as an operator symbol to indicate integer division.[10] This rounds toward zero.
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:,, or .[11]
In APL is called Expand when used to insert fill elements into arrays, and Scan when used to produce prefix reduction (cumulative fold).
In PHP version 5.3 and higher, the backslash is used to indicate a namespace.[12]
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 .[13]
Filenames
MS-DOS 2.0, released 1983, copied the idea of a hierarchical file system from Unix and thus used the (forward) slash as the directory separator.[14] Possibly on the insistence of IBM,[15]
Notes and References
- Macquarie Dictionary (3rd edition)
- Web site: ASCII . Raymond . Eric S . The Jargon File . 2007-07-28 . 2019-01-18 . https://web.archive.org/web/20190118060854/http://catb.org/jargon/html/A/ASCII.html . live .
- Web site: Bulletin 188: Teletype automatic perforator set . 6 . Teletype Corporation . August 1945 . navy-radio.com . 2021-12-19 . 2021-12-19 . https://web.archive.org/web/20211219004736/https://www.navy-radio.com/manuals/tty/188B-4508.pdf . live.
- Web site: Bulletin 1025, issue 3: Parts for Teletype Wheatstone Perforator . 9 . July 1945 . Teletype Corporation . navy-radio.com . 2021-12-19 . 2021-12-19 . https://web.archive.org/web/20211219003141/https://www.navy-radio.com/manuals/tty/tty1025.pdf . live .
- Web site: The Evolution of Character Codes, 1874–1968 . 20 June 2000 . Eric . Fischer . 14–15 (Table 35) . 30 November 2022 . 30 November 2022 . https://web.archive.org/web/20221130065133/http://dump.deadcodersociety.org/ascii.pdf . live . Referencing R.W. . Bemer . W. . Buchholz . An Extended Character Set Standard . TR 00.721 . Product Development Laboratory, Data Systems Division, International Business Machines Corporation . June 1, 1960. Computer Standards Collection, Archives Center, National Museum of American History, Smithsonian Institution, box 1.
- Web site: C compiler source . 1975 . bitsavers.org . 2009-10-11 . 2011-08-15 . https://web.archive.org/web/20110815153104/http://www.bitsavers.org/bits/Interdata/32bit/unix/univWollongong_v6/interdata_v6/usr/source/c/c00.c . live .
- Web site: C compiler source . 1979 . mit.edu . 2009-10-11 . 2013-12-03 . https://web.archive.org/web/20131203022053/http://stuff.mit.edu/afs/sipb/project/v7unix/fs/usr/src/cmd/c/c00.c . live .
- Web site: The C Preprocessor . GNU.org . 2021-01-04 . 2021-08-03 . https://web.archive.org/web/20210803000553/https://gcc.gnu.org/onlinedocs/gcc-3.2.3/cpp/Initial-processing.html . live .
- Book: 3.1.1 Splitting long lines. GNU manual. https://www.gnu.org/software/make/manual/make.html#Splitting-Lines. July 28, 2019. June 5, 2018. https://web.archive.org/web/20180605023853/https://www.gnu.org/software/make/manual/make.html#Splitting-Lines. live.
- Web site: Arithmetic Operators in Visual Basic. Visual Basic Language Features: Operators and Expressions. 10 July 2012 . MSDN. 7 October 2012. 17 September 2012. https://web.archive.org/web/20120917100112/http://msdn.microsoft.com/en-us/library/b6ex274z(v=vs.110).aspx. live.
- Revised Report on the Algorithmic Language Algol 68 . Acta Informatica . 5 . 1–3 . 1–236 . September 1973 . 10.1007/BF00265077 . 2490556 . 2020-02-10 . 2020-07-26 . https://web.archive.org/web/20200726125450/https://ir.cwi.nl/pub/13447 . live .
- Web site: Namespaces overview . php.net . 2012-10-10 . 2012-10-16 . https://web.archive.org/web/20121016184321/http://www.php.net/manual/en/language.namespaces.rationale.php . live .
- O'Sullivan, Stewart, and Goerzen, Real World Haskell, ch. 4: anonymous (lambda) functions, p.99
- Web site: Why is the DOS path character "\"? . Blogs.msdn.com . 2005-06-24 . 2013-06-16 . 2022-11-19 . https://web.archive.org/web/20221119103949/https://learn.microsoft.com/en-us/archive/blogs/larryosterman/why-is-the-dos-path-character . live .
- Web site: Path.GetFullPath Method . .NET Framework Class Library . Microsoft . 2009-01-02. https://web.archive.org/web/20081221114738/http://msdn.microsoft.com/en-us/library/system.io.path.getfullpath.aspx. 21 December 2008 . live.
- Web site: When did Windows start accepting forward slash as a path separator? . Bytes.com . 2009-01-02. https://web.archive.org/web/20090206050805/http://bytes.com/groups/python/23123-when-did-windows-start-accepting-forward-slash-path-separator. 6 February 2009 . live.
- Web site: Microsoft Probes Flaw in ASP.NET . https://archive.today/20130121115529/http://www.devsource.com/c/a/Using-VS/Microsoft-Probes-Flaw-in-ASPNET/ . dead . 2013-01-21 . Kaplan . Simone . Ziff Davis Enterprise Holdings Inc. . DevSource, sponsored by Microsoft . 2004 . 2009-06-14 .
- Web site: Security Holes That Run Deep. Burnett. Mark. SecurityFocus. 2004. 2009-06-14. 2021-02-02. https://web.archive.org/web/20210202211420/https://www.securityfocus.com/columnists/285. live.
- Web site: USFM – Unified Standard Format Markers. paratext.org. 18 April 2017. 30 June 2013. 13 August 2020. https://web.archive.org/web/20200813060533/https://paratext.org/usfm/. live.
- Web site: C0 control characters set, 1987 . pd.infn.it . 2021-03-14 . 2019-09-06 . https://web.archive.org/web/20190906020303/http://wwwcdf.pd.infn.it/AppuntiLinux/a2138.htm#almlanchor1706 . live .
- Web site: Quantities and units – Part 2: Mathematical signs and symbols to be used in the natural sciences and technology. ISO 80000-2:2009. 15 April 2008 . International Organization for Standardization. 2012-10-07. 2014-03-26. https://web.archive.org/web/20140326013017/http://www.iso.org/iso/catalogue_detail?csnumber=31887. live.
- Web site: Definition:Coset Space . ProofWiki . 1 February 2017 . 26 February 2021 . https://web.archive.org/web/20210226163838/https://proofwiki.org/w/index.php?title=Definition:Coset_Space&oldid=227233 . live .
- Web site: Integer Division. mathworld.wolfram.com. 2020-03-10. 2020-02-21. https://web.archive.org/web/20200221154259/http://mathworld.wolfram.com/IntegerDivision.html. live.
- Web site: Eaton. John W.. GNU Octave: A high-level interactive language for numerical computations. Free Software Foundation. 7 October 2012. David Bateman. Søren Hauberg. 145. February 2011. 24 October 2012. https://web.archive.org/web/20121024061422/http://www.gnu.org/software/octave/octave.pdf. live.
- Web site: When is a backslash not a backslash? . Blogs.msdn.com . 2013-06-16 . 2016-03-23 . https://web.archive.org/web/20160323062003/http://www.siao2.com/2005/09/17/469941.aspx . live .
- Web site: RFC 1345 . Tools.ietf.org . 1991-12-26 . 2013-06-16 . Simonsen . Keld . 2016-06-13 . https://web.archive.org/web/20160613195948/https://tools.ietf.org/html/rfc1345 . live .
- Web site: Why Does Windows Really Use Backslash as Path Separator? . 28 May 2019 . Necasek . Michal . 24 May 2019 . OS/2 Museum | archive-url = https://web.archive.org/web/20190524202002/http://www.os2museum.com/wp/why-does-windows-really-use-backslash-as-path-separator/ | archive-date = 24 May 2019 | df = dmy-all }} 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 "" gave the "wide" option to the "" command, so some other method was needed if one actually wanted to run a program called inside a directory called). 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.[15] 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.[16] 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 .[17] [18]
Text markup
The backslash is used in the TeX typesetting system and in RTF files to begin markup tags.
In USFM,[19] the backslash is used to mark format features for editing Bible translations.
In caret notation, represents the control character 0x1C, file separator.[20] This is entirely a coincidence and has nothing to do with its use in file paths.
Mathematics
A backslash-like symbol is used for the set difference.[21]
The backslash is also sometimes used to denote the right coset space.[22]
Especially when describing computer algorithms, it is common to define backslash so that is equivalent to . This is integer division that rounds down, not towards zero. In Wolfram Mathematica the backslash is used this way for integer divide.[23]
In MATLAB and GNU Octave the backslash is used for left matrix divide, while the (forward) slash is for right matrix divide.[24]
Confusion with ¥ and other characters
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.[25]
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".[26] Consequently, this style may be seen in early Internet Engineering Task Force documents.
External links
- Web site: Bob Bemer . How ASCII got its backslash . https://web.archive.org/web/20130719181924/http://www.trailing-edge.com/~bobbemer/BACSLASH.HTM . 2013-07-19.
.