zoukankan      html  css  js  c++  java
  • perl unicode utf-8 x转换

    [root@dr-mysql01 ~]# cat x5.pl
    use Encode;
    use JSON; 
    use URI::Escape;
    use LWP::Simple;
    my $host = "http://ip.taobao.com/service/getIpInfo.php?ip=202.101.172.35";
    my $content = get($host);
    print "$content  is $content
    ";
    
    
    $content =~ s/\u([0-9a-fA-F]{4})/pack("U",,hex($1))/eg; 
    
    print "$content  is $content
    ";
    
    use Data::Dumper;
    
    my $json_out= Dumper($content); 
    print "$json_out is $json_out
    "
    You have mail in /var/spool/mail/root
    [root@dr-mysql01 ~]# perl x5.pl
    $content  is {"code":0,"data":{"country":"u4e2du56fd","country_id":"CN","area":"u534eu4e1c","area_id":"300000","region":"u6d59u6c5fu7701","region_id":"330000","city":"u676du5ddeu5e02","city_id":"330100","county":"","county_id":"-1","isp":"u7535u4fe1","isp_id":"100017","ip":"202.101.172.35"}}
    Wide character in print at x5.pl line 12.
    $content  is {"code":0,"data":{"country":"中国","country_id":"CN","area":"华东","area_id":"300000","region":"浙江省","region_id":"330000","city":"杭州市","city_id":"330100","county":"","county_id":"-1","isp":"电信","isp_id":"100017","ip":"202.101.172.35"}}
    $json_out is $VAR1 = "{"code":0,"data":{"country":"x{4e2d}x{56fd}","country_id":"CN","area":"x{534e}x{4e1c}","area_id":"300000","region":"x{6d59}x{6c5f}x{7701}","region_id":"330000","city":"x{676d}x{5dde}x{5e02}","city_id":"330100","county":"","county_id":"-1","isp":"x{7535}x{4fe1}","isp_id":"100017","ip":"202.101.172.35"}}";

  • 相关阅读:
    Django-admin导出到表格
    Django1.11.4中文文档
    Django+uwsgi+nginx+angular.js项目部署
    angular.js 入门
    枚举类型的总结
    基于websocket的页面聊天程序
    java网络编程(三):一个类似QQ的聊天程序
    java网络编程(二)
    java网络编程(一)
    java中的序列化与反序列化,还包括将多个对象序列化到一个文件中
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350870.html
Copyright © 2011-2022 走看看