Fix to rewind filepointer when testing BOM marker

This commit is contained in:
Mark Baker 2013-06-03 13:40:21 +01:00
parent 7a7634fba6
commit 9c881ea4d1

View File

@ -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;