From cc0e59ad81ba10c65d2928aa5c83b0308f788803 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 14 Apr 2015 11:07:00 +0200 Subject: [PATCH] [SIGNED-OFF] 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 --- 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 890c8ce..b852680 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; @@ -180,7 +179,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; @@ -191,7 +190,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 ) { @@ -201,13 +200,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; } } } @@ -250,11 +249,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.3.5