From: Nat Pryce Date: 2001-08-14T19:36:19+09:00 Subject: [ruby-talk:19687] Re: having to add '\r' for Microsoft hosted telnet daemon (RE: [ruby- talk:19308] Re: PATCH: fixed bug in "waitfor" in net/telnet.rb) From: "Stefan Scholl" > In everey known language "\n" stands for a newline. Not every in known language by any stretch of the imagination! Only those that borrow some syntax from C. > This is a LF on Linux and a CR+LF on DOS. > The Internet RFCs has chosen CR+LF as a newline. > > > "\r" stands for carriage return (CR). If you add a "\r" to a "\n" > you get "\r\n" which is a CR+LF on Linux and a CR+CR+LF on DOS. > > > So, please use "\x0d\x0a" if you want CR+LF, not "\r\n". It's a > common mistake I often read in Perl newsgroups. Maybe I've misunderstood you... On any operating system, DOS included, '\n' is the newline character and '\r' is the carriage return character. The character '\n' is never CR+LF. The C IO libraries convert LF into CR+LF when writing text files, and vice versa when reading text files. Also, there is no difference between the strings "\x0d\x0a" and "\r\n". The syntax \r and \x0d mean the same thing, as do \n and \x0a. E.g. this program p "\n".length p "\r".length p "\n\r".length p "\x0d\x0a" == "\r\n" prints: 1 1 2 true