What is “ANSI as UTF-8” and how can I make fputcsv() generate UTF-8 w/BOM?

前端 未结 4 587
离开以前
离开以前 2020-12-08 11:11

I made a PHP script that generates CSV files that were previously generated by another process. And then, the CSV files have to be imported by yet another process.

T

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 11:44

    According to the Notepad++ related threads here and here, 'ANSI as UTF-8' indicates UTF-8 without BOM, while a plain 'UTF-8' means UTF-8 with BOM. So maybe the process reading the CSV needs the Byte-order mark to correctly read the CSV as UTF-8.

    But before going into that, make sure that your script actually writes UTF-8! When you open the new CSVs in Notepad++ (and it says 'ANSI as UTF-8'), are all 'special' characters displayed correctly? If not, you need to adapt your script to actually write UTF-8, if yes, check for the BOM difference.

提交回复
热议问题