Removing BOM from UTF-8

Gerard Seibert gerard at seibercom.net
Sat Feb 18 11:35:10 PST 2006


Benjamin A'Lee wrote:

> 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

Maybe I am doing something wrong, but it does not appear to be working 
correctly. I named the file nobom.sh and put it in the same directory 
as the files I want to convert. I also set the program permission to 
0755.

typing the p[program name does nothing; I have to precede it with 
'perl'. Even then, it does not appear to work correctly. In the 
following example, the file is parsed, but not converted.

perl nobom.sh testfile

Am I doing something incorrectly here?

Thanks!

-- 
Gerard Seibert
gerard at seibercom.net

PGP: http://www.seibercom.net/sig/gerard.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20060218/4b203084/attachment.bin


More information about the freebsd-questions mailing list