Live data from Hacker News

Why is the DOS path character "\"?

blogs.msdn.com

21–30 of 68 posts

Re: Why is the DOS path character "\"?

#21
post #20
post #18

Earlier quoted context omitted.

Several positions in the table ({ | } [ \ ] @) were meant for "national variants". I guess those characters were deemed unimportant at the time. Here is some more info: http://www.cs.tut.fi/~jkorpela/chars.html#national-ascii

Thus, the characters that appear in those positions - including those in US-ASCII - are somewhat "unsafe" in international data transfer ... Systems that support ISO Latin 1 in principle may still reflect the use of national variants of ASCII in some details; for example, an ASCII character might get printed or displayed according to some national variant. Thus, even "plain ASCII text" is thereby not always portable…

As a wild guess, I would say that in the days before the internet made "international data transfer" something a regular person would encounter frequently, the thought just never occurred to them.

Re: Why is the DOS path character "\"?

#22
post #14

Interestingly, if you ever come to Japan you will find many people expect path separators to be yen symbols (¥). Their windows paths look like: ¥docs¥finance¥ To understand the reason, just check out the table on the Shift-JIS encoding: http://en.wikipedia.org/wiki/Shift_JIS Specifically, look at the character at 0x5C where the backslash sits in ASCII. Learning this was one of those mind-blowing moments when you try…

Same for Korean with the ₩. And you can change the default system locale to Japanese or Korean and see it on any language version of Windows.

Re: Why is the DOS path character "\"?

#23
post #14

Interestingly, if you ever come to Japan you will find many people expect path separators to be yen symbols (¥). Their windows paths look like: ¥docs¥finance¥ To understand the reason, just check out the table on the Shift-JIS encoding: http://en.wikipedia.org/wiki/Shift_JIS Specifically, look at the character at 0x5C where the backslash sits in ASCII. Learning this was one of those mind-blowing moments when you try…

The Korean won symbol ₩ also occupies 0x5C. I never got totally used to seeing directory paths separated by ₩.

Re: Why is the DOS path character "\"?

#24
post #2

This article remind me of my first days of C coding and the problems generated with escaped "c:\haracters in strings". After years I still think that the use of forward slash is the worst decision ever. At least Apple chose ":" on Mac OS classic.

The comments has the story on that, which involved IBM.

Re: Why is the DOS path character "\"?

#25
post #8

Earlier quoted context omitted.

If you're referring to \ it's a backslash not a forward slash.

A simple way to remember forward/backslash (which I probably read on HN) is the phrase "Backslash is by the backspace" Edit: This is for the standard US keyboard. A more general way of thinking about it, though a bit more to remember: associate "positive" with "forward", and see that '/' has a positive slope. Or just go listen to a BBC podcast, and let the sound of the broadcaster saying "bbc dot co dot uk forward-sl…

Alt-shift-7 on a Finnish Mac keyboard. Took me a while to find it the first time.

Re: Why is the DOS path character "\"?

#26
post #8

Earlier quoted context omitted.

If you're referring to \ it's a backslash not a forward slash.

A simple way to remember forward/backslash (which I probably read on HN) is the phrase "Backslash is by the backspace" Edit: This is for the standard US keyboard. A more general way of thinking about it, though a bit more to remember: associate "positive" with "forward", and see that '/' has a positive slope. Or just go listen to a BBC podcast, and let the sound of the broadcaster saying "bbc dot co dot uk forward-sl…

Talking about the BBC: sometimes they say stroke instead of slash, which as an American, really confused me the first time I heard it.

Re: Why is the DOS path character "\"?

#27
What bugs me is that they chose a character right next to "Return" on the keyboard. For some reason no PC keyboard has moved it.

I've had embarrassing MS-DOS moments in the past where I was typing out something like a recursive-delete on a path. If you accidentally hit RETURN instead of a backslash then you can do things like blow away entire parent directories unintentionally. This didn't exactly improve my already-critical view of PCs. :)

Re: Why is the DOS path character "\"?

#28
post #7

Goes deeper than just IBM. Prior to DOS there was CP/M and CP/M had many programs with an older heritage. For example, it was possible to copy from a source (such as a file) to a destination (such as another file, or an I/O port) using a program called PIP ( http://en.wikipedia.org/wiki/Peripheral_Interchange_Program ). On CP/M, for example, you could print a file with the command (PRN: is the name of the printer dev…

You could still do that with copy in MS-DOS, I have a feeling my mom still does it since she has a printer on parallel port. So if she wants to print a textfile it's just

     copy file.txt LPT1
she can also print multiple files or results of print to file using the /b switch (binary) ignoring EOF

That also explains why you shouldn't use LPT1 as file name - it was a special name that meant first parallel port. I remember seeing a ridiculing thread about it on HN some time ago

Re: Why is the DOS path character "\"?

#29
I've always felt the better question is "Why is the UNIX path character "/"?

People use "/" as a date separator as in 12/25/1979 so effectively banning that character as a character in filenames seems a really poor choices. By that metric chosing "\" is a much better choice because "\" is used no where I know outside of computers. I've never encountered it anywhere outside of computers so arguable it's the perfect choice for a path character.

Re: Why is the DOS path character "\"?

#30

The early DOS developers wanted to use "/", so it turns out the underlying OS will accept either / or \. The main trouble you have is that cmd.exe and powershell think \ is the switch character -- so as long as you're not writing programs that write shell scripts or shell out you do OK. Back when I was a Windows dev I drove the guys I worked with nuts because I used "/" instead of "\", figuring it would be more porta…

So I'm sort of nitpicking your comment here, but the purpose of @"" for verbatim strings wasn't created just to deal with directory slashes, it's just a handy way of writing string without the need for escaping in general.

Also, if you really want to make portable C# code, you should use Path.DirectorySeparatorChar, as it's not platform specific at all.

http://msdn.microsoft.com/en-us/library/system.io.path.direc...

Post reply on HN