Problem in Enforcing utf8 coding for output

S

schwertleite

Hi,

I have recently upgraded the Perl version on the my machine from 5.6.1
to 5.8.7 And it seems that thereafter, the files generated by my
certain localise.pl has started failing to output files into the ANSI
code instead of ideal UTF-8 encoding.

Here is the certain line that I have managed to create the correct
utf8 output beforehand

my $output = new IO::File (">$file");

I have tried the following:_

a) my $output = new IO::File(">$file")->utf8->all;
b) my $output = new IO::File(">$file");
$output->utf8->all;
c) my $output = new IO::File(">:utf8",$file);
d) my $output = new IO::File(">:encoding(utf8),$file);
e) use encoding "utf8";

with absolutely no luck.

I am really a newbie to Perl who has exhausted all imagination on the
issue. Therefore any help from the Perl gurus out there will be very
appreciated.


Thanks,
Mency
 
M

Mumia W.

Hi,

I have recently upgraded the Perl version on the my machine from 5.6.1
to 5.8.7 And it seems that thereafter, the files generated by my
certain localise.pl has started failing to output [utf8 ...]

The POD (documentation) for IO::File says this:
METHODS
open( FILENAME [,MODE [,PERMS]] )
open( FILENAME, IOLAYERS )

And since ':utf8' is an IO layer, I suspect that the correct invocation
would be this:

my $output = IO::File->new('output.txt','>:utf8');

And I tested it, and this is correct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,591
Members
45,103
Latest member
VinaykumarnNevatia
Top