in reply to convert a Unicode file to Ansi, using filehandle..

Thanks for the reply guys.

I am using Perl 5.8.9. I tried to create a separate script based from your example. Making 2 different variables for input and output and encoded both input and output..but i am getting these error outputs..

utf8 "\xFF" does not map to Unicode at unicode.pl line 7.
utf8 "\xFE" does not map to Unicode at unicode.pl line 7.

bare with me, my apologies... and thanks...

  • Comment on Re: convert a Unicode file to Ansi, using filehandle..

Replies are listed 'Best First'.
Re^2: convert a Unicode file to Ansi, using filehandle..
by wfsp (Abbot) on Nov 06, 2009 at 12:03 UTC
    That could be a BOM (byte order mark) at the begining of your file. In these cases I've used File::BOM with success. Something along the lines of
    use File::BOM qw( :all ); # ... open_bom(my $fh, $file, q{:utf8}) or die qq{cant open ->$file<- to read: $!\n};