e$B%A%1%C%He(B #1075 e$B$,99?7$5$l$^$7$?!#e(B (by James G.)
Ruby 1.9 uses an all new CSV library. It’s somewhat more strict in it’s
parsing as a means to get dramatically more speed.
Here it is correctly reporting that \r is an illegal character in an
unquoted field. That rule comes from the CSV RFC.
The reason it isn’t treated as a line ending is that the new library
tried to guess your line ending by default. When doing so, the first
thing it saw was the bare \n in the second quoted field. Thus it
assumed the line ending was a \n. However, it looks like the real line
ending here is \r\n.
You can easily fix this by just explicitly setting the line ending, so
CSV won’t guess it, wrongly in this case:
$ ruby_dev -v -rcsv -e ‘p CSV.parse(“a,“b\n”,c\r\n”, row_sep: “\r\n”)’
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9.6.0]
[[“a”, “b\n”, “c”]]
Hope that helps.