Project

General

Profile

Bug #4041

Array#to_csv generates invalid US-ASCII string

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

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-11-10 trunk 29738) [i686-linux]
Backport:
[ruby-core:33135]

Description

=begin
I found Array#to_csv method generates a string with invalid encoding.

% ./ruby -rcsv -ve '
a = ["foo".force_encoding("US-ASCII"), "\u3042"]
p a.map {|v| v.encoding }
s = a.to_csv
p s
p s.encoding'
ruby 1.9.3dev (2010-11-10 trunk 29738) [i686-linux]
[#Encoding:US-ASCII, #Encoding:UTF-8]
"foo,\xE3\x81\x82\n"
#Encoding:US-ASCII

The array to convert to CSV using Array#to_csv contains US-ASCII string and
UTF-8 string.
But the result is US-ASCII string which contains 8-bit bytes.

I think the result should be UTF-8 string.
--
Tanaka Akira
=end

History

#1

Updated by naruse (Yui NARUSE) about 9 years ago

  • Category set to lib
  • Status changed from Open to Assigned
  • Assignee set to JEG2 (James Gray)
  • Priority changed from 3 to Normal
  • ruby -v set to ruby 1.9.3dev (2010-11-10 trunk 29738) [i686-linux]

=begin

=end

#2

Updated by JEG2 (James Gray) about 9 years ago

=begin
I agree that this is a problem. I will look into it.
=end

#3

Updated by JEG2 (James Gray) almost 9 years ago

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

=begin
This issue was solved with changeset r29808.
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