【发布时间】:2011-07-11 19:27:55
【问题描述】:
如果我已经在使用use encoding 'utf8',我可以省略use 'utf8'-pragma 吗?
#!/usr/bin/env perl
use warnings;
use 5.012;
use Encode qw(is_utf8);
use encoding 'utf8';
my %hash = ( '☺' => "☺", '\x{263a}' => "\x{263a}", 'ä' => "ä", 'a' => "a" );
for my $key ( sort keys %hash ) {
say "UTF8 flag is turned on in the STRING $key" if is_utf8( $hash{$key} );
say "UTF8 flag is NOT turned on in the STRING $key" if not is_utf8( $hash{$key} );
}
【问题讨论】:
标签: perl utf-8 character-encoding encode