Removing BOM from UTF-8

Benjamin A'Lee lists at benalee.co.uk
Sat Feb 18 09:26:00 PST 2006


On Sat, 2006-02-18 at 11:28 -0500, Gerard Seibert wrote:
> It has been suggested that a script could be written to eliminate the
> BOM from a file(s). My script writing skills suck. I have been unable to
> locate one using Google, so I was hoping that someone might know where I
> could either locate such a program, or perhaps give me an idea on how to
> script one.

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

That'll read a file from stdin, remove the BOM from the beginning of the
first line if it's present, and print it to stdout.

Hope it helps.

    Ben

-- 
Termisoc Tech Officer: <http://termisoc.org/>
My Homepage: <http://benalee.co.uk/>
"People demand freedom of speech as compensation for the freedom of
thought which they have but seldom use." -- Søren Kierkegaard 


More information about the freebsd-questions mailing list