• 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 "
    ";
    jrhapt01:/home/tomcat/test> perl a2.pl  "u767bu5f55u6210u529f"
    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 "
    ";
    jrhapt01:/home/tomcat/test> perl a2.pl  "u767bu5f55u6210u529f"
    登录成功
    
    
    encode_utf8 作用:
    jrhapt01:/home/tomcat/test> cat a3.pl 
    my $str="中均";
    print "$str is $str
    ";
    
    use Encode;
    print "111111111111111111
    ";
    my $var=  encode_utf8($str);
    print "$var is $var
    ";
    print decode_utf8($var);
    print "
    ";
    
    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 到一个逻辑字符的顺序

  • 相关阅读:
    转:struts2的s:iterator 标签 详解
    转载:jquery 获取和设置 select下拉框的值
    转载:Linux下Tomcat配置
    document、element、node方法
    .NET平台下Web测试工具横向比较
    PhotoShop中让索引图片解锁使用
    改变FileUpLoader 样式 (FileUpLoader js)
    【收藏下】ashx+jQuery,一个轻量级的asp.net ajax解决方案
    TopCoder入门教程
    调用API
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350036.html
Copyright © 2020-2023  润新知