Remove BOM from UTF files.

Implementation similar to suggestion from, and thus closes #83
This commit is contained in:
Matthew de Marillac
2017-11-25 13:07:24 +01:00
committed by Fonata
parent b082849b17
commit ccad5c8360

View File

@@ -838,6 +838,20 @@ class parseCSV {
$data = ltrim($strip[1]);
}
if (strpos($data, "\xef\xbb\xbf") === 0) {
// strip off BOM (UTF-8)
$data = substr($data, 3);
}
else if (strpos($data, "\xff\xfe") === 0) {
// strip off BOM (UTF-16 little endian)
$data = substr($data, 2);
}
else if (strpos($data, "\xfe\xff") === 0) {
// strip off BOM (UTF-16 big endian)
$data = substr($data, 2);
}
if ($this->convert_encoding) {
$data = iconv($this->input_encoding, $this->output_encoding, $data);
}