mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 00:36:38 +00:00
Remove BOM from UTF files.
Implementation similar to suggestion from, and thus closes #83
This commit is contained in:
committed by
Fonata
parent
b082849b17
commit
ccad5c8360
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user