From: Roger Pack Date: 2009-08-08T05:37:06+09:00 Subject: [ruby-core:24810] Re: Is this a bug? D is \r A is \n >> File.open('test.rb', 'w') do |f| f.write "line1\r\nline22"; end >> puts ( File.read('test.rb').inspect) > > The real output of "\r\n" in text mode is 0x0D 0x0D 0x0A in both > 1.8 and 1.9. Good. > And, when single 0x0D exist together to 0x0D 0x0A, it is undefined > how to treat them on reading. > The word ``undefined'' means that ruby doesn't guarantee what occurs. So it is undefined when you read "\r\n\n" in windows without being in binary mode, do I understand correctly? I suppose that's a weakness with using File.read--maybe File.read should default to binary? [I think people probably want it to, and it would then behave the same on linux and windows]. Anyway despite that it is undefined, that it changed from version to version was surprising, but I guess this is such an odd case it's not worth worrying about. Thanks much. -r > As a matter of fact, bccwin32 1.8 treat 0x0D 0x0D 0xA as "\n". > mswin32/mingw32 1.8 treat them as "\r\n". > mswin32/mingw32 1.9 treat them as "\n\n".