In a Rails application, I accept and process CSV files that can be formatted with any of the three possible line termination characters: \n ( LF ), \r\n ( CR+LF ), or \r ( CR ). The Ruby File and CSV libraries seem to do a great job with the first two cases, but the last case (line ending "Mac classic" \r ) is not treated as a new line. It is important to be able to accept this format, as well as others, since Microsoft Excel for Mac (runs on OS X) seems to use it when exporting to "Comma Separated Values" (although exporting to "Windows Comma Separated" makes it easier to -to- handle \r\n ).
Python has "universal newline support" and can handle any of these three formats without problems. Is there something similar in Ruby that will accept all three without knowing the format in advance?
ruby file newline csv line-endings
jrdioko
source share