X-Git-Url: http://git.rot13.org/?p=webpac2;a=blobdiff_plain;f=lib%2FWebPAC%2FInput%2FCSV.pm;h=fc11be7f645175dc02b38049d9cc61499736dcbc;hp=7dcf582a27123d66585f3b75c8ad5e86f5eb5247;hb=3f7a7fa6ea289b2579240e32bfc9ef5f1d745fac;hpb=c4591a1ca51a0ac631ff79bfadfdb9b8e60e24e5 diff --git a/lib/WebPAC/Input/CSV.pm b/lib/WebPAC/Input/CSV.pm index 7dcf582..fc11be7 100644 --- a/lib/WebPAC/Input/CSV.pm +++ b/lib/WebPAC/Input/CSV.pm @@ -67,7 +67,17 @@ sub new { $rec->{'000'} = [ ++$self->{size} ]; my $col = 'A'; - $rec->{ $col++ } = Encode::decode_utf8( $_ ) foreach @$line; + foreach my $cell ( @$line ) { + my $str = eval { Encode::decode_utf8( $cell ) }; + if ( $@ ) { + if ( $@ =~ m/Cannot decode string with wide characters/ ) { + $str = $cell; + } else { + die "ERROR: $@ in line ",dump( $line ); + } + } + $rec->{ $col++ } = $str; + } push @{ $self->{_rec} }, $rec;