How do I remove  from the beginning of a file?

前端 未结 23 1131
攒了一身酷
攒了一身酷 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:46

    BOM is just a sequence of characters ($EF $BB $BF for UTF-8), so just remove them using scripts or configure the editor so it's not added.

    From Removing BOM from UTF-8:

    #!/usr/bin/perl
    @file=<>;
    $file[0] =~ s/^\xEF\xBB\xBF//;
    print(@file);
    

    I am sure it translates to PHP easily.

提交回复
热议问题