zoukankan      html  css  js  c++  java
  • 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 到一个逻辑字符的顺序

  • 相关阅读:
    链接错误error LNK2005可能原因之一
    ACCESS一些特殊数据类型
    flex&bison学习笔记(2)
    经典小故事
    spoj 2939 Query on a tree V 动态树分治
    spoj 913 Query on a tree II 倍增
    CEOI 2004 sweets 容斥原理
    poj 1741 Tree 树的分治
    zjoi 2007 hide 捉迷藏 动态树分治
    spoj 2798 Query on a tree again! 树链剖分
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350036.html
Copyright © 2011-2022 走看看