如果 perl程序的命令行里有 utf8字符,会遇到一些问题,比如:
$ cat 1.pl
use strict;
use warnings;
use utf8;
binmode STDOUT, ':utf8';
my $cmdline = join(' ', @ARGV);
print join(',', split //, $cmdline), "\n";
$ perl 1.pl 我觉得
(乱码)
为了解决这个问题,必须 utf8 decode 一个,为什么?不知道
$ cat 1.pl
use strict;
use warnings;
use utf8;
binmode STDOUT, ':utf8';
my $cmdline = join(' ', @ARGV);
utf8::decode($cmdline);
print join(',', split //, $cmdline), "\n";
$ perl 1.pl 我觉得
我,觉,得
阅读(1441) | 评论(0) | 转发(0) |