zoukankan      html  css  js  c++  java
  • perl decode_utf8

    centos6.5:/root#cat t1.pl 
    use Mojolicious::Lite;  
    use JSON qw/encode_json decode_json/;    
    use Encode;  
    no strict;  
    no utf8;
    use JSON;   
    use Data::Dumper;  
    # /foo?user=sri  
     get '/admin/api/menu' => sub {  
              my $c = shift;  
             open (LOG1 ,"<",'11.out') or die  $!;  
                         while (<LOG1>) {  
                         my $phone='18072722237';  
                        #2016-03-09 09:35:12,380 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为132435,本验证码5分钟内有效。 to phoneNo:18072722237 succeed!  
                          my $d='验证';
                         #my $d='验证';
                        if ( ($phone) and ($_ =~/$phone/) and ($_ =~/$d/) ){$str=$_;  
                           if ($_ =~  /([0-9]{4}-[0-9]{1,2}-[0-9]{2}s+[0-9]{2}:[0-9]{2}:[0-9]{2}.*?)s+(.*?Send message:)s*(.*?)(tos+phoneNo:s*[0-9]{11}).*/){
                           	$a1=$1;
                    	$a2=$2;
                     	$a3=$3;
                      	$a4=$4;
                            print "$a1 is $a1
    ";
                            print "$a2 is $a2
    ";
                            print "$a3 is $a3
    ";
                            print "$a4 is $a4
    ";
                        }};  
                          
                        close LOG1;  
                        my $a=decode_utf8("测试更健康");
                        print "--------------
    ";
                        print length($a);
                        print "--------------
    ";
    
              $c->render(text =>  "$a" );  
    };  
    };
                         
      
      
      app->start;
    centos6.5:/root#morbo t1.pl 
    Server available at http://127.0.0.1:3000
    [Sat Mar 11 13:48:49 2017] [debug] GET "/admin/api/menu"
    [Sat Mar 11 13:48:49 2017] [debug] Routing to a callback
    $a1 is 2016-03-09 09:35:12,380
    $a2 is INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:
    $a3 is 您的验证码为132435,本验证码5分钟内有效。 
    $a4 is to phoneNo:18072722237
    --------------
    5--------------
    [Sat Mar 11 13:48:49 2017] [debug] 200 OK (0.0011s, 909.091/s)
    readline() on closed filehandle LOG1 at /root/t1.pl line
    
    [root@yun-bak ~]# curl http://192.168.11.185:3000/admin/api/menu
    测试更健康[root@yun-bak ~]# 
    
    
    my $a=decode_utf8("测试更健康");
    
    这里需要decode_utf8 转换成utf8 字符
    
    
    [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
    测试更健康

  • 相关阅读:
    laravel 5.5 仓库模式 文件之间接口与实现操作
    php 无线分类 根据子级找父级
    php 无限极分类,根据父级 找子级
    laravel5.4 中 dd和dump的区别。
    laravel hash密码生成和密码验证
    oracle建表详细信息
    关于组件的认识
    java的Thread Dump诊断工具
    weblogic连接池
    详解Oracle数据字典
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349830.html
Copyright © 2011-2022 走看看