Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 编码:使用';utf8';_Perl_Utf 8_Character Encoding_Encode - Fatal编程技术网

Perl 编码:使用';utf8';

Perl 编码:使用';utf8';,perl,utf-8,character-encoding,encode,Perl,Utf 8,Character Encoding,Encode,当我已经在使用使用编码“utf8”时,是否可以省略使用“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 %ha

当我已经在使用
使用编码“utf8”时,是否可以省略
使用“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} );
}

是的,但请确保您熟悉perldoc中的。

官方不鼓励使用编码。该模块不受欢迎,因为它会导致非常奇怪的行为。相反,您应该使用以下选项:

use utf8;                             # Source code is UTF-8
use open ':std', ':encoding(UTF-8)';  # STDIN,STDOUT,STDERR are UTF-8.
见Q: