I'm at a lost...  I still need to do some learning about unicode but
basically I'm reading an unicode utf-16le file and have successfully
done so but with one issue.  When I print the first line of input the
BOM is still there... I was thinking that the BOM would be striped off
during the open then read process but I was wrong.  The print out put
has three characters of garbage at the beginning of the string then
the rest of the output is fine.  I have tried to use a regex to remove
it prior to printing without success.  I'll post the code below and
see if someone can see my issue.  Thanks in advance!

#############code
#!/usr/bin/perl -w
#
use strict;
use warnings;
use Cwd;
use Encode;

my $file1_in = "uft-16 LE file.txt";
my $fh1;
my $line;
my $rc;

open $fh1,"<:raw:encoding(UTF16-LE):crlf:utf8", $file1_in or die
"can't open $file1_in: $!";
binmode STDOUT, ":utf8";

foreach $line (<$fh1>) {
        chomp($line);
        print "$line\n";
    }
    close $fh1;

#########output
∩�[┐2007-05-11 15:34:15.10 Server      Microsoft SQL Server 2005 -
9.00.2050.00 (X64)
...rest of the output is normal...


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to