Bug #4063

Array#to_csv(ascii-subset-of-iso-8859-1, utf-8)

Added by akr (Akira Tanaka) over 1 year ago. Updated about 1 year ago.

[ruby-core:33229]
Status:Closed Start date:
Priority:Low Due date:
Assignee:- % Done:

100%

Category:-
Target version:-
ruby -v:

Description

Array#to_csv still has an encoding problem.

% ./ruby -rcsv -ve '
a = ["foo".force_encoding("ISO-8859-1"), "\u3042"]
puts a[0].dump
puts a[1].dump
p a.map {|v| v.encoding }
s = a.to_csv
puts s.dump
p s.encoding'
ruby 1.9.3dev (2010-11-17 trunk 29809) [i686-linux]
"foo"
"\u{3042}"
[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>]
"foo,\xE3\x81\x82\n"
#<Encoding:ISO-8859-1>

The encoding of the first string is ISO-8859-1 but
contains only ASCII characters.

The encoding of the second string is UTF-8 and
contains a UTF-8 (non-ASCII, non-ISO-8859-1) character.
(The character U+3042 is HIRAGANA LETTER A.)

The encoding of the result of Array#to_csv is ISO-8859-1 but
it contains the bytes of HIRAGANA LETTER A in UTF-8.
-- 
Tanaka Akira

Associated revisions

Revision 29822
Added by JEG2 (James Gray) over 1 year ago

* lib/csv.rb: Upgrading output encoding with ASCII content as needed. [ruby-core:33229]

History

Updated by JEG2 (James Gray) over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
This issue was solved with changeset r29822.
Akira, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

Also available in: Atom PDF