使用 PHP 读取 XLS 文件时的字符编码问题
我正在使用 PHP-Excel-Reader 库阅读了一些 XLS 文件并立即遇到了这个问题:
PHP 通知:
iconv()
[function.iconv]:在第 1718 行的 C:\web\docs\housing\excel_reader2.php 中的输入字符串中检测到不完整的多字节字符
有问题的行是这样的:
$result = iconv('UTF-16LE', $this->_defaultEncoding, $string);
在此之前我添加了一些调试信息以帮助诊断问题:
var_dump($string); // string(10) "A�r�i�a�l�"
echo bin2hex($string) . "\n"; // 41007200690061006c00
echo $this->_defaultEncoding . "\n"; // UTF-8
我尝试将 _defaultEncoding
更改为任意数量的随机字符集,但显然没有帮助。
如果有人有任何线索,请帮忙!
I'm using the PHP-Excel-Reader library to read some XLS files and immediately have hit this issue:
PHP Notice:
iconv()
[function.iconv]: Detected an incomplete multibyte character in input string in C:\web\docs\housing\excel_reader2.php on line 1718
The line in question is this:
$result = iconv('UTF-16LE', $this->_defaultEncoding, $string);
And I've added some debugging info before that 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've tried changing to the _defaultEncoding
to any number of random charsets but it obviously hasn't helped.
If anyone has any clues, please do help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我意识到这是一篇旧帖子,但要检查的一件事是您的 Excel 文件中是否有任何链接。我遇到了完全相同的问题,通过从 Excel 文件中删除所有超链接解决了这个问题。
I realize this is an old post, but one thing to check is if there are any links in your excel file. I ran in to the exact same issue and it was solved by removing any hyperlinks from the excel file.
因为这是一个警告,你可以忽略它,试试这个:
$result = @iconv('UTF-16LE', $this->_defaultEncoding, $string);
since it is a warning you may ignore it try this:
$result = @iconv('UTF-16LE', $this->_defaultEncoding, $string);
尝试 :
try :