[root@yyjk esb]#cat test.pl
use JSON;
use Encode;
my $a='测试';
print length($a);
print "
";
print $a."
";
print '------------------'."
";
my $b=decode_utf8($a);
print length($b);
print "
";
print $b;
print "
";
You have mail in /var/spool/mail/root
[root@yyjk esb]#perl test.pl
6
测试
------------------
2
Wide character in print at test.pl line 11.
测试
[root@yyjk esb]#cat test01.pl
use JSON;
use Encode;
my $a='测试';
print length($a);
print "
";
print $a."
";
print '------------------'."
";
my @a=($a);
print encode_json(@a);
[root@yyjk esb]#perl test01.pl
6
测试
------------------
["测试"][root@yyjk esb]#
[root@yyjk esb]#cat test02.pl
use JSON;
use Encode;
my $a='测试';
my $b=decode_utf8($a);
print length($b);
print "
";
print $b;
print "
";
my @a=($b);
print encode_json(@a);
You have mail in /var/spool/mail/root
[root@yyjk esb]#perl test02.pl
2
Wide character in print at test02.pl line 7.
测试
["测试"][root@yyjk esb]#