On Windows, “\n” evaluates to a carriage return and a line feed, what
you may be used to calling “\r\n”. If you open blaat.txt in SciTE (or
any similar text editor) and view the ends of lines (View -> End of
Line), you’ll see.
So what’s happening is that f.write “test\r\n” is writing a carriage
return, then “\n” which is a carriage return and a line feed.
f.write “test\r\n”
Does anyone know what the problem could be and how to fix it?
any similar text editor) and view the ends of lines (View -> End of
Line), you’ll see.
So what’s happening is that f.write “test\r\n” is writing a carriage
return, then “\n” which is a carriage return and a line feed.
…and if you don’t like the behaviour, use File.open(‘xxxx’, ‘wb’) -
notice the ‘b’.
Or specify mode as IO::WRONLY | IO::BINARY
The same works for Python as well.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.