Project

General

Profile

Actions

Bug #680

closed

csv.rb: CSV.parse is too late when encoding is mismatch

Added by xibbar (Takeyuki FUJIOKA) about 16 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
Backport:
[ruby-core:19465]

Description

=begin
I think this result is true, but encoding mismatch raise is too late.

see:
% time ruby19 -rcsv -e 'CSV.parse(("\x82\xA0,\x82\xA2\n"*10000).force_encoding("shift_jis"))'
ruby19 -rcsv -e 0.30s user 0.02s system 96% cpu 0.330 total

% time ruby19 -rcsv -e 'CSV.parse(("\x82\xA0,\x82\xA2\n"*10000))'
/Users/fujioka/local/lib/ruby/1.9.0/csv.rb:1981:in =~': broken UTF-8 string (ArgumentError) from /Users/fujioka/local/lib/ruby/1.9.0/csv.rb:1981:in init_separators'
from /Users/fujioka/local/lib/ruby/1.9.0/csv.rb:1563:in initialize' from /Users/fujioka/local/lib/ruby/1.9.0/csv.rb:1350:in new'
from /Users/fujioka/local/lib/ruby/1.9.0/csv.rb:1350:in parse' from -e:1:in '
ruby19 -rcsv -e 'CSV.parse(("\x82\xA0,\x82\xA2\n"*10000))' 1.55s user 2.57s system 90% cpu 4.530 total
=end


Files

sample.csv (97.7 KB) sample.csv xibbar (Takeyuki FUJIOKA), 10/24/2008 07:25 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0