From 3f7a7fa6ea289b2579240e32bfc9ef5f1d745fac Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 4 Apr 2016 16:20:37 +0200 Subject: [PATCH] don't try to decode utf-8 strings --- lib/WebPAC/Input/CSV.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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; -- 2.20.1