mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-29 08:46:03 +03:00
Fix to rewind filepointer when testing BOM marker
This commit is contained in:
parent
7a7634fba6
commit
f44b412420
@ -144,28 +144,28 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
|
|||||||
*/
|
*/
|
||||||
protected function _skipBOM()
|
protected function _skipBOM()
|
||||||
{
|
{
|
||||||
rewind($fileHandle);
|
rewind($this->_fileHandle);
|
||||||
|
|
||||||
switch ($this->_inputEncoding) {
|
switch ($this->_inputEncoding) {
|
||||||
case 'UTF-8':
|
case 'UTF-8':
|
||||||
fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ?
|
fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ?
|
||||||
fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-16LE':
|
case 'UTF-16LE':
|
||||||
fgets($this->_fileHandle, 3) == "\xFF\xFE" ?
|
fgets($this->_fileHandle, 3) == "\xFF\xFE" ?
|
||||||
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-16BE':
|
case 'UTF-16BE':
|
||||||
fgets($this->_fileHandle, 3) == "\xFE\xFF" ?
|
fgets($this->_fileHandle, 3) == "\xFE\xFF" ?
|
||||||
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-32LE':
|
case 'UTF-32LE':
|
||||||
fgets($this->_fileHandle, 5) == "\xFF\xFE\x00\x00" ?
|
fgets($this->_fileHandle, 5) == "\xFF\xFE\x00\x00" ?
|
||||||
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-32BE':
|
case 'UTF-32BE':
|
||||||
fgets($this->_fileHandle, 5) == "\x00\x00\xFE\xFF" ?
|
fgets($this->_fileHandle, 5) == "\x00\x00\xFE\xFF" ?
|
||||||
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -187,7 +187,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
|
|||||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||||
}
|
}
|
||||||
$fileHandle = $this->_fileHandle;
|
$fileHandle = $this->_fileHandle;
|
||||||
|
|
||||||
// Skip BOM, if any
|
// Skip BOM, if any
|
||||||
$this->_skipBOM();
|
$this->_skipBOM();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user