jrhapt01:/home/tomcat/test> cat a2.pl 
my $str="$ARGV[0]";
use Encode;
use URI::Escape;
use LWP::Simple;
$str =~ s/\\u([0-9a-fA-F]{4})/pack("U",,hex($1))/eg;
print $str;
print "\n";
jrhapt01:/home/tomcat/test> perl a2.pl "\u767b\u5f55\u6210\u529f"
Wide character in print at a2.pl line 6.
登录成功



jrhapt01:/home/tomcat/test> cat a2.pl
my $str="$ARGV[0]";
use Encode;
use URI::Escape;
use LWP::Simple;
$str =~ s/\\u([0-9a-fA-F]{4})/pack("U",,hex($1))/eg;
print encode_utf8($str);
print "\n";
jrhapt01:/home/tomcat/test> perl a2.pl "\u767b\u5f55\u6210\u529f"
登录成功


encode_utf8 作用:
jrhapt01:/home/tomcat/test> cat a3.pl
my $str="中均";
print "\$str is $str\n";

use Encode;
print "111111111111111111\n";
my $var= encode_utf8($str);
print "\$var is $var\n";
print decode_utf8($var);
print "\n";

jrhapt01:/home/tomcat/test> perl a3.pl
$str is 中均
111111111111111111
$var is 中å
中均

$octets = encode_utf8($string);
Equivalent to "$octets = encode("utf8", $string);" The characters that comprise $string are encoded in Perl’s internal

format and the result is returned as a sequence of octets. All
possible characters have a UTF-8 representation so this function cannot fail.


等价于 "$octets = encode("utf8", $string);"


字符串构成$string 是编码成perl的内部格式,结果是 一个有序的8位字节

所有可能的字符串有一个UTF-8 表示

$string = decode_utf8($octets [, CHECK]);
equivalent to "$string = decode("utf8", $octets [, CHECK])". The sequence of octets represented by $octets is decoded

from UTF-8 into a sequence of logical characters. Not all
sequences of octets form valid UTF-8 encodings, so it is possible for this call to fail. For CHECK, see "Handling

Malformed Data".


等价于 "$string = decode("utf8", $octets [, CHECK])". 8位字节的顺序是被解码从UTF-8 到一个逻辑字符的顺序