From 954cf660780797f8cc658e6bcbe4d082ce314b24 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Wed, 13 Feb 2019 13:25:20 +0100 Subject: [PATCH] Bug 22323: cronjob runreport.pl CSV add encoding MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Cronjob runreport.pl runs SQL reports and can export as CSV. This export needs to be UTF-8 encoded. This pathes replaces use of Text::CSV_XS by Text::CSV::Encoded like in other places like tools/viewlog.pl. It adds a decode of headers bcause they will be encoded lika other lines. Test plan: 1) Create a new item with itemnotes 'accentué' 2) Create a SQL report with : SELECT barcode,itemnotes AS itè FROM items WHERE itemnotes LIKE 'accenté' 3) Run this report 4) You see well encoded header and content 5) Run from command line (replace X by report number) : misc/cronjobs/runreport.pl X --format=csv --csv-header --store-results 6) You well encoded header and content 7) Go to saved reports table 8) Look at saved results of report 9) You well encoded header and content Signed-off-by: Mikaël Olangcay Brisebois Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens (cherry picked from commit 83fe95d0c5d404a2ffc6ed35e822ff0f5ee8b6e6) Signed-off-by: Martin Renvoize (cherry picked from commit 0ad76960cd24b3f12eb5c0e7058f02cd13ba1ac0) Signed-off-by: Lucas Gass (cherry picked from commit bde83720d4f1995bf5047f9429545a56bda3eddc) Signed-off-by: Fridolin Somers --- misc/cronjobs/runreport.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl index 848a405bba..c0f8bdf683 100755 --- a/misc/cronjobs/runreport.pl +++ b/misc/cronjobs/runreport.pl @@ -29,7 +29,7 @@ use Koha::DateUtils; use Getopt::Long qw(:config auto_help auto_version); use Pod::Usage; use MIME::Lite; -use Text::CSV_XS; +use Text::CSV::Encoded; use CGI qw ( -utf8 ); use Carp; use Encode; @@ -269,7 +269,8 @@ foreach my $report_id (@ARGV) { } $message = $cgi->table(join "", @rows); } elsif ($format eq 'csv') { - my $csv = Text::CSV_XS->new({ + my $csv = Text::CSV::Encoded->new({ + encoding_out => 'utf8', binary => 1, quote_char => $quote, sep_char => $separator, -- 2.39.5