How can I output a UTF-8 CSV in PHP that Excel will read properly?

后端 未结 30 2471
半阙折子戏
半阙折子戏 2020-11-22 06:08

I\'ve got this very simple thing that just outputs some stuff in CSV format, but it\'s got to be UTF-8. I open this file in TextEdit or TextMate or Dreamweaver and it displa

30条回答
  •  一向
    一向 (楼主)
    2020-11-22 06:09

    Converting already utf-8 encoded text by using mb_convert_encoding is not needed. Just add three characters in front of the original content:

    $newContent = chr(239) . chr(187) . chr(191) . $originalContent
    

    For me this resolved the problem of special characters in csv files.

提交回复
热议问题