Project

General

Profile

Bug #4063

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

Added by akr (Akira Tanaka) almost 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-core:33229]

Description

=begin
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
=end

History

#1

Updated by JEG2 (James Gray) almost 9 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
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.

=end

Also available in: Atom PDF