zoukankan      html  css  js  c++  java
  • perl encode_utf8 和decode_utf8

      encode_utf8
    
      $octets = encode_utf8($string);
      
      相当于  $octets = encode("utf8", $string). 
      
      这个字符串在$string 是被编码成Perl的内部格式, 结果是返回 a sequence of octets. 
      
      8位字节的顺序
      
      decode_utf8
    
      $string = decode_utf8($octets [, CHECK]);
      
      
      相当于  $string = decode("utf8", $octets [, CHECK]).  
      
      the sequence of octets 
      
      8位字节的顺序 通过$octets 是被解码从UTF-8 到一个逻辑字符的顺序
      
    [oracle@oadb utf-8]$ cat a1.pl 
    use Encode;
    my $str="测试更健康";
    print length($str);
    print "
    ";
    print $str."
    ";
    [oracle@oadb utf-8]$ perl a1.pl 
    15
    测试更健康
    
    
    [oracle@oadb utf-8]$ cat a1.pl 
    use Encode;
    my $str="测试更健康";
       $str=encode_utf8($str);
    print length($str);
    print "
    ";
    print $str."
    ";
    [oracle@oadb utf-8]$ perl a1.pl 
    30
    æµè¯æ´å¥åº·
    [oracle@oadb utf-8]$ 
      
      
      
    
    
    
    [oracle@oadb utf-8]$ cat a1.pl 
    use Encode;
    my $str="测试更健康";
       $str=decode_utf8($str);
    print length($str);
    print "
    ";
    print $str."
    ";
    [oracle@oadb utf-8]$ perl a1.pl 
    5
    Wide character in print at a1.pl line 6.
    测试更健康
    

  • 相关阅读:
    左偏树
    output html
    jsp web.xml
    mysql link db
    beamline
    jsp embend java into html / mix scriptlets and HTML
    StringTokenizer
    TreeSet
    centOS 显示中文
    request and response
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349824.html
Copyright © 2011-2022 走看看