Skip to content
Prev 62163 / 63421 Next

[External] readChar() could read the whole file by default?

On 29/01/2024 1:09 p.m., Toby Hocking wrote:
These two things aren't the same:

   paste(readLines(f), collapse = "\n")

is not the same as

   readChar(f, file.size(f))

in cases where the file has Windows-style newlines and you're reading it 
on Unix, because the first one converts the CR LF newlines into \n, 
while the second would give \r\n.  I think they would match for reading 
Unix-style files on Windows.)

Does this ever matter?  I don't know, but I think usually people would 
want the behaviour of paste(readLines(f), collapse = "\n").

Duncan Murdoch