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.
This commit is contained in:
bgenere 2016-11-28 14:23:35 +01:00
parent e59edca855
commit b81a1a9a1d

View File

@ -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";