Jump to content

Backslash: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Excirial (talk | contribs)
m Reverted edits by 8.24.98.130 (talk) (HG 3)
Line 2: Line 2:
The '''backslash''' ('''\''') is a typographical mark ([[glyph]]) used mainly in [[computing]] and is the [[mirror image]] of the common [[slash (punctuation)|slash (/)]]. It is sometimes called a '''hack''', '''whack''', '''[[escape character|escape]]''' (from [[C (programming language)|C]]/[[UNIX]]), '''reverse slash''', '''slosh''', '''backslant''', '''downhill''', '''backwhack''', and in rare occasions, '''bash''', '''reverse slant''', and '''reversed virgule'''.<ref>''[[Macquarie Dictionary]]'' (3rd edition)</ref><ref>{{cite web | url=http://www.catb.org/jargon/html/A/ASCII.html | title=ASCII | last=Raymond | first=Eric S}}</ref> In Unicode, it is encoded at {{unichar|005C|REVERSE SOLIDUS|html=}}.
The '''backslash''' ('''\''') is a typographical mark ([[glyph]]) used mainly in [[computing]] and is the [[mirror image]] of the common [[slash (punctuation)|slash (/)]]. It is sometimes called a '''hack''', '''whack''', '''[[escape character|escape]]''' (from [[C (programming language)|C]]/[[UNIX]]), '''reverse slash''', '''slosh''', '''backslant''', '''downhill''', '''backwhack''', and in rare occasions, '''bash''', '''reverse slant''', and '''reversed virgule'''.<ref>''[[Macquarie Dictionary]]'' (3rd edition)</ref><ref>{{cite web | url=http://www.catb.org/jargon/html/A/ASCII.html | title=ASCII | last=Raymond | first=Eric S}}</ref> In Unicode, it is encoded at {{unichar|005C|REVERSE SOLIDUS|html=}}.


==
==History==
{{redirects here|\/|the letter|V}}
[[Bob Bemer]] introduced the "\" character into [[ASCII]]<ref>{{cite web|url=http://www.thocp.net/biographies/bemer_bob.htm |title=Mini-Biography of Bob Bemer |publisher=Thocp.net |accessdate=2013-06-16}}</ref> on September 18, 1961,<ref name=how /> as the result of character frequency studies. In particular the '''\''' was introduced so that the [[ALGOL 68#Standard dyadic operators with associated priorities|ALGOL boolean operators]] '''[[Logical conjunction|&and;]]''' (AND) and '''[[Logical disjunction|&or;]]''' (OR) could be composed in ASCII as "<tt>/\</tt>" and "<tt>\/</tt>" respectively.<ref name=how>[http://www.bobbemer.com/BACSLASH.HTM "How ASCII Got Its Backslash"], Bob Bemer</ref><ref>{{cite web |author=Bob Bemer |title=The Great Curly Brace Trace Chase |url=http://home.ccil.org/~remlaps/www.bobbemer.com/BRACES.HTM |work=Computer History Vignettes |publisher=Bob Bemer |date=2002-07-07 |accessdate=2009-10-11}}</ref> Both these operators were included in early versions of the [[C (programming language)|C programming language]] supplied with Unix V6<!-- http://www.bitsavers.org/bits/Interdata/32bit/unix/univWollongong%5Fv6/interdata%5Fv6/usr/source/c/c00.c(1975) -->, Unix V7 <!-- http://stuff.mit.edu/afs/sipb/project/v7unix/fs/usr/src/cmd/c/c00.c (1979) --> and more currently BSD 2.11<!-- http://en.wikipedia.org/wiki/Berkeley%5FSoftware%5FDistribution#cite%5Fnote-2.11bsd-0 (1992–2008)-->.


==Usage==
==Usage==

Revision as of 19:22, 12 May 2014

The backslash (\) is a typographical mark (glyph) 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, backslant, downhill, backwhack, and in rare occasions, bash, reverse slant, and reversed virgule.[1][2] In Unicode, it is encoded at U+005C \ REVERSE SOLIDUS (&bsol;).

==

Usage

In many programming languages such as C, Perl, and PHP 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 thus an escape character. In various regular expression languages it acts as a switch, changing subsequent literal characters into metacharacters 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, λ).[3]

In the context of line-oriented text, especially source code for some programming languages, 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."[4]

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 at the command line interpreter's prompt 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).[5] 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 as well.[6] This holds true for MS-DOS and PC DOS, but also all other DOS operating systems like DR-DOS, PTS-DOS, RxDOS or FreeDOS as well as to Concurrent DOS, Multiuser DOS, FlexOS, 4680 OS, 4690 OS, OS/2 and Windows. In some versions of DOS, the option character can be changed from / to - via SWITCHAR, which also makes COMMAND.COM accept / as alternative path delimiter.

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

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 MS-DOS filenames.[10] 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 Ö (German, Swedish), Ø (Danish, Norwegian), ç (French) and Ñ (Spanish), leading to similar problems. Since the character was originally not available in all character sets and keyboard layouts, ANSI C can transcribe it in form of the trigraph ??/ which, outside string literals, is equivalent to the \ character. RFC 1345 recommends to transcribe the character as digraph //, if not available.[11]

In mathematics, a backslash-like symbol is used for the set difference.[12]

In some dialects of the BASIC programming language, the backslash is used as an operator symbol to indicate integer division.[13]

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

In PHP version 5.3 and higher, the backslash is used to indicate a namespace.[15]

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

References

  1. ^ Macquarie Dictionary (3rd edition)
  2. ^ Raymond, Eric S. "ASCII".
  3. ^ O'Sullivan, Stewart, and Goerzen, Real World Haskell, ch. 4: anonymous (lambda) functions, p.99
  4. ^ "GNU 'make' manual". Gnu.org. Retrieved 2013-06-16.
  5. ^ "Why is the DOS path character "\"?". Blogs.msdn.com. 2005-06-24. Retrieved 2013-06-16.
  6. ^ "Path.GetFullPath Method". .NET Framework Class Library. Microsoft. Archived from the original on 21 December 2008. Retrieved 2009-01-02. {{cite web}}: Unknown parameter |deadurl= ignored (|url-status= suggested) (help)
  7. ^ "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. {{cite web}}: Unknown parameter |deadurl= ignored (|url-status= suggested) (help)
  8. ^ Kaplan, Simone (2004). "Microsoft Probes Flaw in ASP.NET". DevSource, sponsored by Microsoft. Ziff Davis Enterprise Holdings Inc. Retrieved 2009-06-14.
  9. ^ Burnett, Mark (2004). "Security Holes That Run Deep". SecurityFocus. Retrieved 2009-06-14.
  10. ^ "When is a backslash not a backslash?". Blogs.msdn.com. Retrieved 2013-06-16.
  11. ^ "RFC 1345". Tools.ietf.org. 1991-12-26. Retrieved 2013-06-16.
  12. ^ "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.
  13. ^ "Arithmetic Operators in Visual Basic". Visual Basic Language Features: Operators and Expressions. MSDN. Retrieved 7 October 2012.
  14. ^ Eaton, John W. (February 2011). "GNU Octave: A high-level interactive language for numerical computations" (PDF). Free Software Foundation. p. 145. Retrieved 7 October 2012. {{cite web}}: Unknown parameter |coauthors= ignored (|author= suggested) (help)
  15. ^ "Namespaces overview".