Why eat my "\r" at windows?

a = (“abc” * 20 + “\r\n”) * 3
File.open(“a.txt”, “wb” ){|x| x.write a}

s = open(“a.txt”).read
p s.count("\r") # why == 0 ?

Your second open opens it (in default) in non binary mode, so it
translates “\r\n” to “\n”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs