From: Daniel Brumbaugh Keeney Date: 2007-11-21T06:17:41+09:00 Subject: Re: Why does IO.readlines() keep newlines? On Nov 20, 2007 2:53 AM, Xavier Noria wrote: > On Nov 20, 2007, at 12:43 AM, Daniel Brumbaugh Keeney wrote: > > > I'm going to speculate that readlines does this because of operating > > system differences in line endings. > > For compatibility between most systems, it would have to remove line > > feeds (\x0A) or line-feed/carriage return combinations (\x0D\x0A). > > Indeed that's not the case. > > In CRLF platforms the I/O layer handles newlines in text mode so that > the programmer *always* works with "\n", no CRLF ever goes up on > Windows. Nor you need to print CRLFs by hand at the Ruby level. At the > Ruby level a newline is always == "\n" and has always length 1. > -- fxn Unfortunately, files created on one platform inevitably make their way to another. When an IO with \r\n is read on a UNIX, it preserves the carriage return. Daniel Brumbaugh Keeney