From: Bill Kelly Date: 2010-06-26T08:44:29+09:00 Subject: Re: marshalled data in 1.9 Roger Pack wrote: >> irb(main):002:0> File.open("zz", "w") {|io| io.write >> "foo\r\nbar\nbaz\n"} >> => 16 >> irb(main):003:0> File.read("zz") >> => "foo\n\nbar\nbaz\n" >> >> >> Notice the "\r\n" came back as "\n\n". > > This feels like a bug to me... If I could pick one statement to summarize my feeling about developing on Windows, that might be it. ;P But anyway... It's not strictly a ruby issue. I recall encountering CRLF text mode vs. binary mode issues in DOS with Borland C in the mid 1980's. But, back to the ruby example above... I don't see how one could expect the data to survive a round trip. Note that if we force ruby to deal with a single character at a time, the results are consistent with the above: irb(main):004:0> File.open("zz2", "w") {|io| "foo\r\nbar\nbaz\n".each_char {|c| io.write c; io.flush}} => "foo\r\nbar\nbaz\n" irb(main):005:0> File.open("zz2", "r") {|io| x=c=""; x << c while (c = io.getc); x} => "foo\n\nbar\nbaz\n" So... it's not clear to me how round-trip semantics could be implemented given the need to consider each character individually? Regards, Bill