# \[Bug #1075\](Rejected) \\r\\n $B$H(B \\n $B$,:.:\_$7$?(B CSV $B$,%(%i!\<$K$J$k(B

**URL:** <https://www.ruby-forum.com/t/bug-1075-rejected-r-n-b-h-b-n-b-7-b-csv-b-i-k-j-k-b/168586>\
**Category:** Development\
**Created:** [May 22, 2009, 6:00pm UTC](https://www.ruby-forum.com/t/bug-1075-rejected-r-n-b-h-b-n-b-7-b-csv-b-i-k-j-k-b/168586 "2009-05-22T18:00:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [May 22, 2009, 6:00pm UTC](https://www.ruby-forum.com/t/bug-1075-rejected-r-n-b-h-b-n-b-7-b-csv-b-i-k-j-k-b/168586/1 "2009-05-22T18:00:31Z")

</div>

e$B%A%1%C%He(B #1075 e$B$,99?7$5$l$^$7$?!#e(B (by James G.)

e$B%9%F!\<%?%9e(B Opene$B$+$ie(BRejectede$B$KJQ99e(B

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.

* * *

[http://redmine.ruby-lang.org/issues/show/1075](http://redmine.ruby-lang.org/issues/show/1075)
