php-excel-reader - problem with UTF-8

前端 未结 2 736
一个人的身影
一个人的身影 2021-01-02 08:03

I\'m using php-excel-reader 2.21 for converting XLS file to CSV. I wrote a simple script to do that, but I have some problems with unicode characters. It does not return val

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-02 08:53

    I hope it's the same problem as I had: In excel_reader2.php on line 1120, replace

    $retstr = ($asciiEncoding) ? $retstr : $this->_encodeUTF16($retstr);
    

    with

    $retstr = ($asciiEncoding) ? iconv('cp1250', 'utf-8', $retstr) : $this->_encodeUTF16($retstr);
    

    That should fix it, however I suggest you use a different excel reader, such as PHPExcel to avoid problems like these.
    Note that you need iconv extension enabled on the server.

提交回复
热议问题