@@ -, +, @@ Bug 6554 - make Koha utf-8 clean This patch tries to clean up utf-8 handling in Koha. In current implementation (mostly commented out in this patch) uses heuristic to guess which strings need decoding from utf-8 to binary representation and doesn't support utf-8 characters in templates and has problems with utf-8 data from database. With this changes, Koha perl code always uses utf-8 encoding correctly. All incomming data from database is allready correctly marked as utf-8, and decoding of utf8 is required only from Zebra and XSLT transfers which don't set utf-8 flag correctly. For output, standard perl :utf8 handler is used removing various "wide character" warnings as side-effect. --- a/C4/ItemType.pm +++ a/C4/ItemType.pm @@ -78,7 +78,7 @@ sub all { for ( @{$dbh->selectall_arrayref( "SELECT * FROM itemtypes ORDER BY description", { Slice => {} })} ) { - utf8::encode($_->{description}); +# utf8::encode($_->{description}); push @itypes, $class->new($_); } return @itypes; --- a/C4/Output.pm +++ a/C4/Output.pm @@ -301,6 +301,7 @@ sub output_with_http_headers($$$$;$) { # utf8::encode($data) if utf8::is_utf8($data); + binmode( STDOUT, ":utf8" ); print $query->header($options), $data; } --- a/C4/Search.pm +++ a/C4/Search.pm @@ -476,6 +476,7 @@ sub getRecords { for ( my $j = 0 ; $j < $jmax ; $j++ ) { my $render_record = $results[ $i - 1 ]->record($j)->render(); +utf8::decode($render_record); my @used_datas = (); foreach my $fcode (@fcodes) { --- a/C4/Templates.pm +++ a/C4/Templates.pm @@ -117,7 +117,7 @@ sub output { utf8_hashref($vars->{$k}); } else { - utf8::encode($vars->{$k}) if utf8::is_utf8($vars->{$k}); +# utf8::encode($vars->{$k}) if utf8::is_utf8($vars->{$k}); } } my $data; @@ -138,7 +138,7 @@ sub utf8_arrayref { utf8_hashref($element); next; } - utf8::encode($element) if utf8::is_utf8($element); +# utf8::encode($element) if utf8::is_utf8($element); } } @@ -153,7 +153,7 @@ sub utf8_hashref { utf8_hashref($hashref->{$key}); next; } - utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); +# utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); } } --- a/C4/XSLT.pm +++ a/C4/XSLT.pm @@ -176,6 +176,7 @@ sub XSLTParse4Display { } my $results = $stylesheet->transform($source); my $newxmlrecord = $stylesheet->output_string($results); +utf8::decode( $newxmlrecord ); return $newxmlrecord; }