Bug 15290: (follow-up)SQL reports headers encoding problem
Fix SQL row data and headers enconding problem To test: -Apply patches -Follow previous test plan -Notice the headers and row data is displayed in UTF-8 without double encoding -Save in Comma separated text, Tab seprated text, and Open Document. -Verify in the three options the file exported is Ok Signed-off-by: Frédéric Demians <f.demians@tamil.fr> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
29cd4ae9bd
commit
4f6bcc5cc9
1 changed files with 3 additions and 2 deletions
|
@ -816,6 +816,7 @@ elsif ($phase eq 'Export'){
|
|||
if ($format eq 'tab') {
|
||||
$type = 'application/octet-stream';
|
||||
$content .= join("\t", header_cell_values($sth)) . "\n";
|
||||
$content = Encode::decode('UTF-8', $content);
|
||||
while (my $row = $sth->fetchrow_arrayref()) {
|
||||
$content .= join("\t", @$row) . "\n";
|
||||
}
|
||||
|
@ -823,10 +824,10 @@ elsif ($phase eq 'Export'){
|
|||
my $delimiter = C4::Context->preference('delimiter') || ',';
|
||||
if ( $format eq 'csv' ) {
|
||||
$type = 'application/csv';
|
||||
my $csv = Text::CSV::Encoded->new({ encoding_out => 'utf8', sep_char => $delimiter});
|
||||
my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter});
|
||||
$csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag();
|
||||
if ($csv->combine(header_cell_values($sth))) {
|
||||
$content .= $csv->string(). "\n";
|
||||
$content .= Encode::decode('UTF-8', $csv->string()) . "\n";
|
||||
} else {
|
||||
push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue