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

前端 未结 4 627
离开以前
离开以前 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:24

    It is worth noting that ANSI as UTF-8, i.e. UTF-8 without the BOM is useful if you are formatting your PHP files as UTF-8. If your PHP file is outputting html to the browser then the BOM is included in the HTML output which the w3c validator explicitly warns against:

    Byte-Order Mark found in UTF-8 File.

    The Unicode Byte-Order Mark (BOM) in UTF-8 encoded files is known to cause problems for some text editors and older browsers. You may want to consider avoiding its use until it is better supported.

    Further to this, I spotted that the BOM confuses Firefox's Firebug which now thinks that all your content is actually in the tag.

提交回复
热议问题