Closed janko closed 6 years ago
Haha, this is a great idea. Doh :p
Haha, this is a great idea. Doh :p
I am going to add a spec for this too.
@ioquatix I tried, but I wasn't sure how. I thought that when a file is opened in UTF-8 mode, that #read
will return the data in UTF-8 encoding and we can test against that. #read
without argument has that behaviour, but it seems that with the length
argument the data is always returned in binary encoding, regardless of whether the file has been opened in binary mode.
It's generally safer to open the file in binary mode, because then C won't try to do any conversions between representations of newlines depending on the OS, it will just retrieve bytes as is. See Avdi's RubyTapas for more details: https://www.rubytapas.com/2016/12/14/ruby-code-on-windows/