Only call iconv if input and output encoding differ.

This saves some headache if characters are invalid according to iconv.
This commit is contained in:
Christian Bläul
2017-11-25 13:47:54 +01:00
committed by Fonata
parent 4d011827f5
commit 0ac5064d58

View File

@@ -843,19 +843,18 @@ class parseCSV {
$data = substr($data, 3);
$this->encoding('UTF-8');
}
else if (strpos($data, "\xff\xfe") === 0) {
elseif (strpos($data, "\xff\xfe") === 0) {
// strip off BOM (UTF-16 little endian)
$data = substr($data, 2);
$this->encoding("UCS-2LE");
}
else if (strpos($data, "\xfe\xff") === 0) {
elseif (strpos($data, "\xfe\xff") === 0) {
// strip off BOM (UTF-16 big endian)
$data = substr($data, 2);
$this->encoding("UTF-16");
}
if ($this->convert_encoding) {
if ($this->convert_encoding && $this->input_encoding !== $this->output_encoding) {
$data = iconv($this->input_encoding, $this->output_encoding, $data);
}