in reply to Encoding horridness revisited: What's going on here? [SOLVED]
Hi Karl,
What do i miss?
As I understand it, you missed telling Perl to encode your STDOUT output as UTF-8, after you read it in the second time (from the file). You don't need to (should not) do so when printing the output of cat, since your terminal already handles the encoding correctly.
use strict; use warnings; use feature qw(say); use utf8; # <-- needed, since you have high characters in your source my $file = q(weird.txt); open( my $fh, '>', $file ); binmode $fh, ':encoding(UTF-8)'; say $fh qq(nase\ngöre); close $fh; say qx (file -I $file); say qx(echo \$LANG); say qx(cat $file); open( $fh, '<', $file ); binmode $fh, ':encoding(UTF-8)'; binmode STDOUT, ':encoding(UTF-8)'; # <-- here say <$fh>; close $fh; __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Encoding horridness revisited: What's going on here?
by choroba (Cardinal) on Jul 13, 2017 at 14:08 UTC | |
by karlgoethebier (Abbot) on Jul 13, 2017 at 16:00 UTC | |
|
Re^2: Encoding horridness revisited: What's going on here?
by karlgoethebier (Abbot) on Jul 13, 2017 at 17:28 UTC |