Removing BOM from UTF-8
Gerard Seibert
gerard at seibercom.net
Sat Feb 18 13:14:56 PST 2006
Gerard Seibert wrote:
> enjamin A'Lee wrote:
>
> > From:
> > "Benjamin A'Lee" <lists at benalee.co.uk>
> > To:
> > freebsd-questions at freebsd.org
> > Date:
> > Today 03:29:34 pm
> >
> >
> > On Sat, 2006-02-18 at 14:34 -0500, Gerard Seibert wrote:
> > > 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.
> >
> > Sorry; try changing the first line to #!/usr/local/bin/perl
> >
> > > perl nobom.sh testfile
> > >
> > > Am I doing something incorrectly here?
> >
> > Try:
> >
> > cat testfile | nobom.sh
> >
> > Though the way you describe appears to work here:
> >
> > $ cat bom-testfile | hd
> > 00000000 ef bb bf 23 20 42 4f 4d 20 74 65 73 74 20 66 69 |...# BOM
> > test fi| 00000010 6c 65 0a
> > |le.| 00000013
> > $ bomkill.pl bom-testfile | hd
> > 00000000 23 20 42 4f 4d 20 74 65 73 74 20 66 69 6c 65 0a |# BOM
> > test file.| 00000010
> >
> >
> > Ben
>
> Something appears to be wrong here. First, the file will not run unless
> I precede it with 'perl'. I have another perl script in the same
> directory that runs just fine without any special prefixes. Also, the
> script does not seem to remove the BOM entity.
>
> This is the script as I have it entered:
>
> #!/usr/local/bin/perl
> use warnings;
> use diagnostics -verbose;
> @file=<>;
> $file[0] =~ s/^\xEF\xBB\xBF//;
> print(@file);
>
> I have the file permissions set to 0755. Is there anything else that
> could be causing this to fail?
>
> This is the first line of the file I am attempting to fix (well one of
> them).
>
> Subject:
>
> That is what appears when I use pico to view the file.
>
As I continue to play with this, it has become apparent that the new
file is not being written, or at least I cannot locate it. Since I do
not know perl, I have no idea where to look for answers.
--
Gerard Seibert
gerard at seibercom.net
More information about the freebsd-questions
mailing list