Eugen Konkov Eugen Konkov - 3 years ago 385
Perl Question

how to get rid of `Wide character in print at`?

I have file

with next content:

00000000 D0 BA D0 B8 │ D1 80 D0 B8 │ D0 BB D0 B8 │ D0 BA к и р и л и к

When I read content of file and print it I get the error:

Wide character in print at ...

The source is:

use utf8;
open my $fh, '<:encoding(UTF-8)', '/tmp/xxx';
print scalar <$fh>

The output from print is:


Answer Source

You're printing to STDOUT which isn't expecting UTF8. Add

binmode(STDOUT, "encoding(UTF-8)");

to change that on the already opened handle.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download