Wes Gamble wrote:
>> I am sure that I have a text file with Windows newlines (CRLF) embedded 
>> in it
>>
>> This doesn't work:
>>
>> newline = "\C-J\C-M"
>> puts IO.read(@document.path) =~ /#{newline}/

And then:
> Apparently just matching on \n works.
> 
> So, Ruby is really smart enough to use \n as a platform-independent 
> newline character?  Impressive.

Ruby on Windows automatically replaces \r\n with \n on input and
vice-versa on output unless you tell open to use binary mode:

irb> File.open("test.txt","w") {|f| f.print "\n" } # write, normal mode
=> nil
irb> File.open("test.txt","r") {|f| f.read } # read, normal mode
=> "\n"
irb> File.open("test.txt","rb") {|f| f.read } # read, binary mode
=> "\r\n"
irb> File.open("test.txt","wb") {|f| f.print "\n" } # write, binary mode
=> nil
irb> File.open("test.txt","rb") {|f| f.read }
=> "\r\n"

Cheers,
Dave