Backslash

The backslash \ is a typographical mark used mainly in computing and is the mirror image of the common slash /. It is sometimes called a hack, whack, escape (from C/UNIX), reverse slash, slosh, downwhack, backslant, backwhack, bash, reverse slant, and reversed virgule.[1][2] In Unicode and ASCII it is encoded at U+005C \ REVERSE SOLIDUS (92decimal).

\
Backslash
In UnicodeU+005C \ REVERSE SOLIDUS (HTML \)
 ⧵   ⧹ 
Reverse solidus operator Big reverse solidus Fullwidth reverse solidus

HistoryEdit

Bob Bemer introduced the \ character into ASCII[3] on September 18, 1961,[4] 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.[4][5] Both these operators were included in early versions of the C programming language supplied with Unix V6, Unix V7 and more recently BSD 2.11.

UsageEdit

Programming languagesEdit

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 normally), or normally (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 "continuation"[6] as the current line continues into the next one.

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 was removed in C++17.

In Visual BASIC (and some other BASIC dialects) the backslash is used as an operator symbol to indicate integer division.[7] 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: 6.0221415e23, 6.0221415E23, 6.0221415\23 or 6.02214151023.[8]

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.[9]

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, λ).[10]

FilenamesEdit

MS-DOS 2.0, released 1983, copied the hierarchical file system from Unix and thus used the (forward) slash[11] but (possibly on the insistence of IBM[12]) added the backslash to allow paths to be typed at the command line interpreter's prompt while retaining compatibility with MS-DOS 1.0 where the slash was the command-line option indicator (typing "DIR/W" gave the "wide" option to the "DIR" command, so some other method was needed if you 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.[13] 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.[14] 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.[15][16]

Text markupEdit

The backslash is used in the TeX typesetting system and in RTF files to begin markup tags.

In USFM,[17] the backslash is used to mark format features for editing Bible translations.

MathematicsEdit

A backslash-like symbol is used for the set difference.[18]

The backslash is also sometimes used to denote the right coset space.[19]

Especially when describing computer algorithims, it is common to define backslash so that a\b is equivalent to a/b.[citation needed] This is integer division that rounds down, not towards zero. In Wolfram Mathematica the backslash is used this way for integer divide.[20]

In MATLAB and GNU Octave the backslash is used for left matrix divide, while the slash is for right matrix divide.[21]

Confusion with ¥ and other charactersEdit

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 (¥). Due to extensive use of the backslash code point 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 (Korean), Ö (German, Swedish), Ø (Danish, Norwegian), ç (French) and Ñ (Spanish), leading to similar problems. Computer programs still treat the code as a backslash in these environments, causing confusion, especially in MS-DOS filenames.[22]

RFC 1345 recommends to transcribe the backslash as // if not available.[23]

ReferencesEdit

  1. ^ Macquarie Dictionary (3rd edition)
  2. ^ Raymond, Eric S. "ASCII".
  3. ^ "Mini-Biography of Bob Bemer". Thocp.net. Retrieved 2013-06-16.
  4. ^ a b "How ASCII Got Its Backslash" Archived 2013-01-19 at the Wayback Machine, Bob Bemer
  5. ^ Bob Bemer (2002-07-07). "The Great Curly Brace Trace Chase". Computer History Vignettes. Bob Bemer. Archived from the original on 2009-06-04. Retrieved 2009-10-11.
  6. ^ "3.1.1 Splitting long lines". GNU make manual. Retrieved July 28, 2019.
  7. ^ "Arithmetic Operators in Visual Basic". Visual Basic Language Features: Operators and Expressions. MSDN. Retrieved 7 October 2012.
  8. ^ "Revised Report on the Algorithmic Language Algol 68". Acta Informatica. 5 (1–3): 1–236. September 1973. doi:10.1007/BF00265077.
  9. ^ "Namespaces overview".
  10. ^ O'Sullivan, Stewart, and Goerzen, Real World Haskell, ch. 4: anonymous (lambda) functions, p.99
  11. ^ "Why is the DOS path character "\"?". Blogs.msdn.com. 2005-06-24. Retrieved 2013-06-16.
  12. ^ 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.
  13. ^ "Path.GetFullPath Method". .NET Framework Class Library. Microsoft. Archived from the original on 21 December 2008. Retrieved 2009-01-02.
  14. ^ "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.
  15. ^ 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.
  16. ^ Burnett, Mark (2004). "Security Holes That Run Deep". SecurityFocus. Retrieved 2009-06-14.
  17. ^ "USFM – Unified Standard Format Markers". paratext.org.
  18. ^ "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.
  19. ^ "Definition:Coset Space". ProofWiki. Retrieved 1 February 2017.
  20. ^ https://mathworld.wolfram.com/IntegerDivision.html. Missing or empty |title= (help)
  21. ^ 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.
  22. ^ "When is a backslash not a backslash?". Blogs.msdn.com. Retrieved 2013-06-16.
  23. ^ "RFC 1345". Tools.ietf.org. 1991-12-26. Retrieved 2013-06-16.

External linksEdit