From 30ed77dae60018b66d6f6f1813d67d3dbef51725 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 14 Apr 2015 11:07:00 +0200 Subject: [PATCH] Bug 11603: Fix encoding issues (bug 11944 is now pushed) Signed-off-by: Frederic Demians No more encoding issue with html file, no problem with csv|ods Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- misc/cronjobs/gather_print_notices.pl | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/misc/cronjobs/gather_print_notices.pl b/misc/cronjobs/gather_print_notices.pl index 9697e3dbd1..b2b5293b15 100755 --- a/misc/cronjobs/gather_print_notices.pl +++ b/misc/cronjobs/gather_print_notices.pl @@ -9,8 +9,7 @@ BEGIN { eval { require "$FindBin::Bin/../kohalib.pl" }; } -use - CGI; # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy +use CGI qw( utf8 ); # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy use C4::Context; use C4::Dates; use C4::Debug; @@ -184,7 +183,7 @@ sub generate_html { messages => $messages, ); - open my $OUTPUT, '>', $filepath + open my $OUTPUT, '>encoding(utf-8)', $filepath or die "Could not open $filepath: $!"; print $OUTPUT $template->output; close $OUTPUT; @@ -195,7 +194,7 @@ sub generate_csv { my $messages = $params->{messages}; my $filepath = $params->{filepath}; - open my $OUTPUT, '>', $filepath + open my $OUTPUT, '>encoding(utf-8)', $filepath or die "Could not open $filepath: $!"; my ( @csv_lines, $headers ); foreach my $message ( @$messages ) { @@ -205,13 +204,13 @@ sub generate_csv { # We don't have headers, get them unless ( $headers ) { $headers = $lines[0]; - say $OUTPUT Encode::encode( 'UTF8', $headers ); + say $OUTPUT $headers; } shift @lines; for my $line ( @lines ) { next if $line =~ /^\s$/; - say $OUTPUT Encode::encode( 'UTF8', $line ); + say $OUTPUT $line; } } } @@ -254,11 +253,11 @@ sub generate_ods { shift @lines; # remove headers my $i = 1; for my $line ( @lines ) { - my $row_data = split $delimiter, $line; + my @row_data = split $delimiter, $line; my $row = $doc->getRow( $table, $i ); # Note scalar(@$row_data) should be equal to $nb_cols - for ( my $j = 0 ; $j < scalar(@$row_data) ; $j++ ) { - my $value = Encode::encode( 'UTF8', $row_data->[$j] ); + for ( my $j = 0 ; $j < scalar(@row_data) ; $j++ ) { + my $value = Encode::encode( 'UTF8', $row_data[$j] ); $doc->cellValue( $row, $j, $value ); } $i++; -- 2.39.5