モダンPerl#32でTerm::Encodingを知った

1
2
3
4
5
6
7
8
9
# utf8
use 5.8.1;
use strict;
use warnings;
use utf8;
use Data::Dumper;
use Term::Encoding qw(term_encoding);
my $encoding = term_encoding;
print Dumper $encoding;
1
$VAR1 = 'cp932';
1
2
3
4
5
6
7
8
9
# utf8
use 5.8.1;
use strict;
use warnings;
use utf8;
use Term::Encoding qw(term_encoding);
my $encoding = term_encoding;
binmode STDOUT => ":encoding($encoding)";
print "ハローワールド!";
1
2
3
4
5
6
7
8
9
# utf8
use 5.8.1;
use strict;
use warnings;
use utf8;
use Encode;
use Term::Encoding qw(term_encoding);
my $enc = Encode::find_encoding(term_encoding);
print $enc->encode("ハローワールド!");

Comments

comments powered by Disqus