Re: New FAQ: Removing UTF-8 BOM

Deborah - here is the perl code that removes the bom:

This is the version by Jonathan Coxhead, given on the Unicode
list:

       #!/usr/bin/perl -pi~ -0777
       # program to remove a leading UTF-8 BOM from a file
       # works both STDIN -> STDOUT and on the spot (with filename as argument)
       s/^\xEF\xBB\xBF//s;


It can even be typed directly, as:

prompt>  perl -pi~ -0777 -e "s/^\xEF\xBB\xBF//s;" filewithbom.html

This uses some very convenient options of perl.


Regards,   Martin.

Received on Wednesday, 5 November 2003 08:40:30 UTC