morgon has asked for the wisdom of the Perl Monks concerning the following question:
I can do this to print a unicode-string to a file:
This works as expected.use strict; use Encode; use utf8; my $string = "üöä"; open my $fh, ">:encoding(UTF-8)", $file or die $!; print $fh $in;
However when I try to add the encoding layer to STDOUT it does not seem to work:
Redirecting this script's output to a file results in a latin1-encoded file.use strict; use Encode; use utf8; my $string = "üöä"; binmode STDOUT, ">:encoding(UTF-8)"; print $string;
Why is that?
Many thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: printing unicode to STDOUT
by ikegami (Patriarch) on Feb 02, 2011 at 17:05 UTC | |
Re: printing unicode to STDOUT
by Anonyrnous Monk (Hermit) on Feb 02, 2011 at 17:16 UTC | |
Re: printing unicode to STDOUT
by elef (Friar) on Feb 02, 2011 at 19:20 UTC |