#Idiomatically read file if it contains new lines or carriage returns and new line

5 messages · Page 1 of 1 (latest)

unreal saffron
#

Is there a way to idiomatically read a file, line by line if the file could be from windows (including /r/n) or on *nix (/n)?

soft charm
#

you want to read it line by line? and worry \r in the file ?

unreal saffron
#

There might be a carriage return in there as we have windows users who are committing files and have autocrlf on

soft charm
#

it'll work just the same (in most cases), bufio could handle both kind of line break.

#

though you can trim the \r suffix while reading, if there is any.