How do I remove  from the beginning of a file?

前端 未结 23 1343
攒了一身酷
攒了一身酷 2020-11-22 06:21

I have a CSS file that looks fine when I open it using gedit, but when it\'s read by PHP (to merge all the CSS files into one), this CSS has the following characters prepend

23条回答
  •  迷失自我
    2020-11-22 06:36

    Three words for you:

    Byte Order Mark (BOM)

    That's the representation for the UTF-8 BOM in ISO-8859-1. You have to tell your editor to not use BOMs or use a different editor to strip them out.

    To automatize the BOM's removal you can use awk as shown in this question.

    As another answer says, the best would be for PHP to actually interpret the BOM correctly, for that you can use mb_internal_encoding(), like this:

     
    

提交回复
热议问题