PHP export CSV when data having UTF8 charcters

后端 未结 4 1458
花落未央
花落未央 2021-02-14 03:49

In MySQL I have set my data field type to utf8_bin and i am storing data in Unicode. Texts are being properly displayed in web pages.

I want to generate ex

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-14 04:32

    I have a variant to Sajal response and found it on php.net at : http://www.php.net/manual/en/function.iconv.php#104287

    Echo this at the begining of the content of the csv :

    chr(255).chr(254).iconv("UTF-8", "UTF-16LE//IGNORE", $data)
    

    I prefer with iconv() but it seems it do the same as mb_convert_encoding(). Don't forget to replace ; by tabs (\t) and it worked fine for me like this !

提交回复
热议问题