How can I stop Ruby from converting "\r\n" to "\n" when using File#readline? -
my code works on linux. when move code on windows, ruby automatically converts "\r\n" line endings "\n" makes strings 1 character short, in turn leads errors when use line length file#seek
calls.
rather working around issue seeking 1 character or converting line endings back, i'd rather prevent ruby changing them in first place. can done?
i had assumed read mode "rb" force "ascii-8bit" encoding of input. reading the docs bit closer, turns out can both use "rb" read mode disable crlf line endings , explicitly pass internal , external encodings normal.
in other words, perfect solution no work involved.
Comments
Post a Comment