From: "Aleksi Niemelä" Date: 2000-07-20T19:27:36+02:00 Subject: [ruby-talk:04148] Inconsistent file access on Windows ports My Wintoys seems to behave differently with two distributions and each time not in a way I'm expecting: str = 10.chr+13.chr+10.chr+13.chr+"foo" outf = File.new("foo", "w") outf.write(str) outf.close inf = File.new("foo") str2 = inf.read(8) puts( (str == str2), str.size, str2.size) p str, str2 (str2.size).times do |i| puts str2[i] end Outputs: rbcw145\ruby test_3.rb true 7 7 "\n\r\n\rfoo" "\n\r\n\rfoo" 10 13 10 13 102 111 111 rbdj145\ruby test_3.rb false 7 6 "\n\r\n\rfoo" "\n\r\nfoo" 10 13 10 102 111 111 Of these two, cygwin (rbcw) seems to be more consistent, and dj-version loses latter ascii 13 somewhere. In any case my hex editor outputs the file content as "0D 0A 0D 0D 0A 0D 66 6F 6F". And dir says the length of the file is 9. Somehow both read and sysread (and writes) duplicate 10.chr to (13.chr,10.chr) in real file. I wonder what it should be. I'd expect "0A 0D 0A 0D 66 6F 6F", after all that's what I'm trying to stuff there. I save you from the story how I did end up with this code, but let's say I was trying to copy files by hand and my end result was few kilos fatter than the original. The moral of the story is probably "always use original!" :) - Aleksi Ps. I didn't post this to the bug list, because I didn't knew if it was a bug, a feature or one of those bugs in my head.