Jump to content

Backslash: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Reverted edits by 8.24.98.130 (talk) to last revision by IronGargoyle (HG)
Line 7: Line 7:


==Usage==
==Usage==
In many [[programming language]]s such as [[C (programming language)|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 [[metacharacter]]s and vice versa. The backslash is used similarly in the [[TeX]] [[typesetting]] system and in [[Rich Text Format|RTF]] files to begin markup tags. In [[Haskell (programming language)|Haskell]], the backslash is used both to introduce special characters and to introduce [[anonymous function|lambda functions]] (since it is a reasonable approximation in ASCII of the Greek letter lambda, λ).<ref>O'Sullivan, Stewart, and Goerzen, ''Real World Haskell'', ch. 4: anonymous (lambda) functions, p.99 </ref>

{{anchor|line-continuation}}
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 (software)|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."<ref>{{cite web|url=http://www.gnu.org/software/make/manual/make.html |title=GNU 'make' manual |publisher=Gnu.org |accessdate=2013-06-16}}</ref>

[[MS-DOS]] 2.0, released 1983, copied the hierarchical file system from Unix and thus used the (forward) [[slash (punctuation)|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 "<tt>DIR/W</tt>" to give the "wide" option to the "<tt>[[DIR (command)|DIR]]</tt>" command).<ref>{{cite web|url=http://blogs.msdn.com/larryosterman/archive/2005/06/24/432386.aspx |title=Why is the DOS path character "\"? |publisher=Blogs.msdn.com |date=2005-06-24 |accessdate=2013-06-16}}</ref> Except for [[COMMAND.COM]], all other parts of the operating system accept both characters in a [[path (computing)|path]], but the Microsoft convention remains to use a backslash, and [[Application programming interface|APIs]] that ''return'' paths use backslashes as well.<ref>
{{cite web
| url = http://msdn.microsoft.com/en-us/library/system.io.path.getfullpath.aspx
| title = Path.GetFullPath Method
| work = .NET Framework Class Library
| publisher = Microsoft
| accessdate = 2009-01-02
| archiveurl= http://web.archive.org/web/20081221114738/http://msdn.microsoft.com/en-us/library/system.io.path.getfullpath.aspx| archivedate= 21 December 2008 <!--DASHBot-->| deadurl= no}}</ref> 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<!-- MS-DOS/PC DOS 2.xx-3.xx, all versions of DR-DOS since 5.0, as well as PTS-DOS and FreeDOS, but not in FlexOS, 4680 OS, 4690 OS. -->, the option character can be changed from <code>/</code> to <code>-</code> via [[SWITCHAR]], which also makes COMMAND.COM accept <code>/</code> 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 [[Quotation mark|double-quotes]].<ref>
{{cite web
| url = http://bytes.com/groups/python/23123-when-did-windows-start-accepting-forward-slash-path-separator
| title = When did Windows start accepting forward slash as a path separator?
| publisher = Bytes.com
| accessdate = 2009-01-02
| archiveurl= http://web.archive.org/web/20090206050805/http://bytes.com/groups/python/23123-when-did-windows-start-accepting-forward-slash-path-separator| archivedate= 6 February 2009 <!--DASHBot-->| deadurl= no}}</ref> 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 <code><nowiki>http://example.net/secure\private.aspx</nowiki></code>.<ref>{{cite web
| url=http://www.devsource.com/c/a/Using-VS/Microsoft-Probes-Flaw-in-ASPNET/
| title=Microsoft Probes Flaw in ASP.NET
| last=Kaplan
| first=Simone
| publisher=Ziff Davis Enterprise Holdings Inc.
| work=DevSource, sponsored by Microsoft
| year=2004
| accessdate=2009-06-14}}</ref><ref>{{cite web
| url=http://www.securityfocus.com/columnists/285
| title=Security Holes That Run Deep
| last=Burnett
| first=Mark
| publisher=SecurityFocus
| year=2004
| accessdate=2009-06-14}}</ref>

In the [[Japanese language|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 language|Korean]] encoding, it is drawn as a [[Won sign|won currency symbol]] (₩). Computer programs still treat the code as a backslash in these environments, causing confusion, especially in MS-DOS filenames.<ref>{{cite web|url=http://blogs.msdn.com/michkap/archive/2005/09/17/469941.aspx |title=When is a backslash not a backslash? |publisher=Blogs.msdn.com |accessdate=2013-06-16}}</ref> 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 [[C trigraph|trigraph]] <code>??/</code> which, outside [[string literal]]s, is equivalent to the <code>\</code> character. [[RFC 1345]] recommends to transcribe the character as [[Digraph (computing)|digraph]] <code>//</code>, if not available.<ref name="RFC1345">{{cite web|url=http://tools.ietf.org/html/rfc1345 |title=RFC 1345 |publisher=Tools.ietf.org |date=1991-12-26 |accessdate=2013-06-16}}</ref>

In [[mathematics]], a backslash-like symbol is used for the [[complement (set theory)|set difference]].<ref>{{cite web|title=Quantities and units -- Part 2: Mathematical signs and symbols to be used in the natural sciences and technology|url=http://www.iso.org/iso/catalogue_detail?csnumber=31887|work=ISO 80000-2:2009|publisher=International Organization for Standardization}}</ref>

In some dialects of the [[BASIC]] programming language, the backslash is used as an operator symbol to indicate [[Integer (computer science)|integer]] [[Division (mathematics)|division]].<ref>{{cite web|title=Arithmetic Operators in Visual Basic|url=http://msdn.microsoft.com/en-us/library/b6ex274z(v=vs.110).aspx|work=Visual Basic Language Features: Operators and Expressions|publisher=MSDN|accessdate=7 October 2012}}</ref>

In [[MATLAB]] and [[GNU Octave]] the backslash is used for left [[Matrix division|matrix divide]], while the slash is for right matrix divide.<ref>{{cite web|last=Eaton|first=John W.|title=GNU Octave: A high-level interactive language for numerical computations|url=http://www.gnu.org/software/octave/octave.pdf|publisher=Free Software Foundation|accessdate=7 October 2012|coauthors=David Bateman, Søren Hauberg|page=145|date=February 2011}}</ref>

In [[PHP]] version 5.3 and higher, the backslash is used to indicate a [[namespace]].<ref>{{cite web|url=http://php.net/manual/en/language.namespaces.rationale.php|title=Namespaces overview}}</ref>

In [http://paratext.org/usfm USFM], the backslash is used to mark format features for editing [[Bible translations]].


== References ==
== References ==

Revision as of 19:23, 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;).

History

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 currently BSD 2.11.

Usage

References

  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", Bob Bemer
  5. ^ Bob Bemer (2002-07-07). "The Great Curly Brace Trace Chase". Computer History Vignettes. Bob Bemer. Retrieved 2009-10-11.