projects
/
webpac2
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c4591a1
)
don't try to decode utf-8 strings
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Mon, 4 Apr 2016 14:20:37 +0000
(16:20 +0200)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Mon, 4 Apr 2016 14:20:37 +0000
(16:20 +0200)
lib/WebPAC/Input/CSV.pm
patch
|
blob
|
history
diff --git
a/lib/WebPAC/Input/CSV.pm
b/lib/WebPAC/Input/CSV.pm
index
7dcf582
..
fc11be7
100644
(file)
--- 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;