Issue #4603 has been updated by theirishpenguin (Declan McGrath).


Hi,

I seem to be still getting this problem on Ruby 1.9.2p290 revision 32553. This issue should be fixed in revision 32553, correct? (as 32553 > 31370)


See below for test case.

Regards,
Declan


Test case
---------

1) Contents of test.csv are:
รก,b
1,2

2) Steps to reproduce issue:
declan@foo:~$ ruby -v
  ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
declan@foo:~$ irb
irb(main):004:0> Encoding::default_internal = 'UTF-8'
  => "UTF-8"
irb(main):007:0> Encoding::default_external = 'UTF-8'
  => "UTF-8"
irb(main):009:0> require 'csv'
  => true
irb(main):010:0> CSV.read('test.csv')
  => [["\xC3\xA1", "b"], ["1", "2"]]
----------------------------------------
Bug #4603: lib/csv.rb: when the :encoding parameter is not provided, the encoding of CSV data is treated as ASCII-8BIT
https://bugs.ruby-lang.org/issues/4603#change-26565

Author: nobuoka (yu nobuoka)
Status: Closed
Priority: Normal
Assignee: JEG2 (James Gray)
Category: lib
Target version: 1.9.2
ruby -v: -


=begin
This issue is involved in three methods, CSV::open, CSV::read and CSV::foreach.

The document of CSV::read says "This method also understands an additional 
:encoding parameter that you can use to specify the Encoding of the data 
in the file to be read. You must provide this unless your data is in 
Encoding::default_external()."
However, when the :encoding parameter is not provided, the encoding of the CSV data 
is treated as ASCII-8BIT. Not as Encoding.default_external.
CSV::open and CSV::foreach are also similar. 

I think the actual behaviour of these methods doesn't conform to the document of these.
=end



-- 
http://bugs.ruby-lang.org/