Project

General

Profile

Actions

Bug #4041

closed

Array#to_csv generates invalid US-ASCII string

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

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

Actions #1

Updated by naruse (Yui NARUSE) over 13 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

Actions #2

Updated by JEG2 (James Gray) over 13 years ago

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

Actions #3

Updated by JEG2 (James Gray) over 13 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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0