Project

General

Profile

Actions

Bug #4063

closed

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

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

Status:
Closed
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

Actions

Also available in: Atom PDF

Like0
Like0