Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Wide character in print

by choroba (Cardinal)
on Jan 22, 2014 at 10:27 UTC ( [id://1071586]=note: print w/replies, xml ) Need Help??


in reply to Wide character in print

print without a file handle prints to STDOUT. You have to turn on the UTF-8 encoding for the STDOUT handle, as well as you correctly did for the input:
binmode STDOUT, ':encoding(UTF-8)';

Or, use open:

use open OUT => ':encoding(UTF-8)', ':std';
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Wide character in print
by Jim (Curate) on Jan 26, 2014 at 00:11 UTC

    Alternatively, PetreAdi can set the character encoding of both input and output to UTF-8 in one fell swoop like this:

    use strict; use warnings; use open qw( :encoding(UTF-8) :std ); use autodie qw( open close ); my $filename = 'data.txt'; open my $fh, '<', $filename; while (my $row = <$fh>) { print $row; } close $fh; exit 0;

    I like to use autodie, too.

    Jim

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1071586]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 23:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found