/**
* CSV File parsing methods
*
* @param $fic
* @param $data
* @param $encoding (default 1)
**/
static function parseLine($fic, $data, $encoding = 1)
{
global $DB;
$csv = array();
$num = count($data);
for ($c = 0; $c < $num; $c++) {
//If field is not the last, or if field is the last of the line and is not empty
if ($c < $num - 1 || $c == $num - 1 && $data[$num - 1] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) {
$tmp = trim($DB->escape($data[$c]));
switch ($encoding) {
//If file is ISO8859-1 : encode the datas in utf8
case PluginDatainjectionBackend::ENCODING_ISO8859_1:
if (!Toolbox::seems_utf8($tmp)) {
$csv[0][] = utf8_encode($tmp);
} else {
$csv[0][] = $tmp;
}
break;
case PluginDatainjectionBackend::ENCODING_UFT8:
$csv[0][] = $tmp;
break;
default:
//PluginDatainjectionBackend :: ENCODING_AUTO :
$csv[0][] = PluginDatainjectionBackend::toUTF8($tmp);
}
}
}
return $csv;
}