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 $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 到一个逻辑字符的顺序

转载于:https://www.cnblogs.com/zhaoyangjian724/p/6198990.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值