From b81a1a9a1d3c522809ba56dac2d6c2b67b38244f Mon Sep 17 00:00:00 2001 From: bgenere Date: Mon, 28 Nov 2016 14:23:35 +0100 Subject: [PATCH] Code was setting ISO charset as default wich was causing an issue with transnoentities as this method send back UTF-8. Result was that CSV file was generated empty (tested on Unix Ubuntu workstation). Replaced now with $conf->file->character_set_client so it works for me (using UTF-8 by default. To complete the fix my feeling is that we should not force charset till we are not writing the final result. But needs to be confirmed by a senior Dolibarr developer. --- .../modules/export/export_csv.modules.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index 8d35ff63225..0c01ef07d89 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -177,6 +177,7 @@ class ExportCsv extends ModeleExports */ function write_header($outputlangs) { + return 0; } @@ -189,18 +190,23 @@ class ExportCsv extends ModeleExports * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK + * + * //TODO transnoentities send back UTF-8 so using an ISO charset at this point create an issue + * (get a blank screen and an empty file) + * my feeling is that we should not force charset till we are not writing the final result. */ function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types) { + global $conf; - + if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET)) { $outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET; } else { - $outputlangs->charset_output = 'ISO-8859-1'; + $outputlangs->charset_output = $conf->file->character_set_client; } foreach($array_selected_sorted as $code => $value) @@ -211,6 +217,7 @@ class ExportCsv extends ModeleExports fwrite($this->handle,$newvalue.$this->separator); } fwrite($this->handle,"\n"); + return 0; } @@ -223,6 +230,10 @@ class ExportCsv extends ModeleExports * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK + * + * //TODO transnoentities send back UTF-8 so using an ISO charset at this point create an issue + * (get a blank screen and an empty file) + * my feeling is that we should not force charset till we are not writing the final result. */ function write_record($array_selected_sorted,$objp,$outputlangs,$array_types) { @@ -234,7 +245,7 @@ class ExportCsv extends ModeleExports } else { - $outputlangs->charset_output = 'ISO-8859-1'; + $outputlangs->charset_output = $conf->file->character_set_client; } $this->col=0; @@ -303,7 +314,7 @@ class ExportCsv extends ModeleExports { global $conf; $addquote=0; - + dol_syslog("ExportCsv::csvClean ".$newvalue); // Rule Dolibarr: No HTML //print $charset.' '.$newvalue."\n";