Character encoding issues when reading XLS files with PHP

I am using PHP-Excel-Reader library to read some XLS files and immediately got into this problem:

PHP Note: iconv()

[function.iconv]: An incomplete multibyte character was encountered in the input line at C: \ web \ docs \ housing \ excel_reader2.php at line 1718

The relevant line is:

$result = iconv('UTF-16LE', $this->_defaultEncoding, $string);

      

And I've added some debug info to help diagnose the problem:

var_dump($string);                   // string(10) "A r i a l "
echo bin2hex($string) . "\n";        // 41007200690061006c00
echo $this->_defaultEncoding . "\n"; // UTF-8

      

I tried to switch to _defaultEncoding

any number of random encodings, but obviously it didn't help.

If anyone has any hints please help!

+2


source to share


3 answers


I understand this is an old post, but need to check if there are any references in your excel file. I faced the same problem and it was solved by removing any hyperlinks from the excel file.



+3


source


since this is a warning, you can ignore it:



$ result = @iconv ('UTF-16LE', $ this β†’ _ defaultEncoding, $ string);

+1


source


try:

$result = iconv('UTF-16LE', $this->_defaultEncoding . "//IGNORE", $string);

      

0


source







All Articles