Hi all,
after reading Encoding horridness i played around a bit:
#!/usr/bin/env perl
# $Id: weird.pl,v 1.3 2017/07/13 09:06:54 karl Exp karl $
use strict;
use warnings;
use feature qw(say);
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)';
say <$fh>;
close $fh;
__END__
This is leading to:
karls-mac-mini:monks karl$ ./weird.pl
weird.txt: text/plain; charset=utf-8
de_DE.UTF-8
nase
göre
nase
göre
And if i say use utf8; i get:
karls-mac-mini:monks karl$ ./weird.pl
weird.txt: text/plain; charset=utf-8
de_DE.UTF-8
nase
göre
nase
g?re
What do i miss?
Thanks for any hint and best regards, Karl
Update: Two working solutions:
Update2: Sorry, wrong merits.
1nickt:
#!/usr/bin/env perl
# $Id: weird_1nickt.pl,v 1.2 2017/07/13 17:10:29 karl Exp karl $
+
use strict;
use warnings;
use feature qw(say);
use utf8;
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)';
say <$fh>;
close $fh;
__END__
karls-mac-mini:monks karl$ ./weird_1nickt.pl
weird.txt: text/plain; charset=utf-8
de_DE.UTF-8
nase
göre
nase
göre
choroba:
#!/usr/bin/env perl
# $Id: weird_choroba.pl,v 1.2 2017/07/13 20:47:38 karl Exp karl
+$
use strict;
use warnings;
use feature qw(say);
use utf8;
use open IO => ':encoding(utf-8)', ':std';
my $file = q(weird.txt);
open( my $fh, '>', $file );
say $fh qq(nase\ngöre);
close $fh;
say qx (file -I $file);
say qx(echo \$LANG);
say qx(cat $file);
open( $fh, '<', $file );
say <$fh>;
close $fh;
__END__
karls-mac-mini:monks karl$ ./weird_choroba.pl
weird.txt: text/plain; charset=utf-8
de_DE.UTF-8
nase
göre
nase
göre
«The Crux of the Biscuit is the Apostrophe»
perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help