From 96da4aff569addb66fcd5cf22ca07c0753438412 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 17 Apr 2013 10:26:39 -0300 Subject: [PATCH] Bug 10068 - Replace the utf8 pragma at C4/Biblio.pm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit utf8::decode($string) for Encode::decode('UTF-8',$string) Added Carp and error handling. Sponsored-by: Universidad Nacional de Córdoba --- C4/Biblio.pm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 7af8619..09f9863 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -23,12 +23,12 @@ use strict; use warnings; use Carp; -# use utf8; use MARC::Record; use MARC::File::USMARC; use MARC::File::XML; use POSIX qw(strftime); use Module::Load::Conditional qw(can_load); +use Encode; use C4::Koha; use C4::Dates qw/format_date/; @@ -2257,9 +2257,6 @@ sub TransformHtmlToXml { @$values[$i] =~ s/"/"/g; @$values[$i] =~ s/'/'/g; - # if ( !utf8::is_utf8( @$values[$i] ) ) { - # utf8::decode( @$values[$i] ); - # } if ( ( @$tags[$i] ne $prevtag ) ) { $j++ unless ( @$tags[$i] eq "" ); my $indicator1 = eval { substr( @$indicator[$j], 0, 1 ) }; @@ -2394,11 +2391,15 @@ sub TransformHtmlToMarc { foreach my $param_name ( keys %$cgi_params ) { if ( $param_name =~ /^tag_/ ) { my $param_value = $cgi_params->{$param_name}; - if ( utf8::decode($param_value) ) { + eval { $param_value = decode('UTF-8', $param_value, + Encode::FB_CROAK); }; + + if ( $@ ) { + # FIXME - need to do something if string is not valid UTF-8 + carp "Error decoding $param_value: $@"; + } else { $cgi_params->{$param_name} = $param_value; } - - # FIXME - need to do something if string is not valid UTF-8 } } -- 1.7.10.4