• HTML::Entities 编码或解码 HTML 实体的字符串


    <pre name="code" class="html"><pre name="code" class="python">HTML::Entities  编码或解码 HTML 实体的字符串
    
     use HTML::Entities;
    
     $a = "Våre norske tegn bør æres";
     decode_entities($a);
     encode_entities($a, "200-377");
     
     比如, this:
     
      $input = "vis-à-vis Beyoncé's naïve
    papier-mâché résumé";
     print encode_entities($input), "
    "
     
     
     描述:
     该模块处理字符串的encoding和decoding 使用HTML 字符实例,
     
     模块提供下面的功能:
     
     decode_entities( $string, ... )
     
     本程序 替换找到的HTML实体在$string 使用相应的Unicode 字符,
     
     未被识别的实体被单独留下
     
     
     如果多个字符串被提供作为参数, 他们是每个单独的解码和相同数量的字符串被返回
     
     
     例子:
     [root@dr-mysql01 ~]# cat a1.pl 
    use  LWP::UserAgent;
    use HTML::Entities;
     
    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    $ua->env_proxy;
    $ua->agent("Mozilla/8.0");
    
    
    my $response = $ua->get('http://192.168.33.9:8088/DEVOPS/index.php/Codequery/search_ip?ip=192.168.32.15');
    
    
    
    
    if ($response->is_success) {
     $rr= $response->decoded_content;  # or whatever
     print "$rr is $rr
    ";
    }
    else {
     die $response->status_line;
    };
    
    
    
    
    $out=decode_entities($rr);
    print "$out is $out
    ";
    [root@dr-mysql01 ~]# perl a1.pl 
    Wide character in print at a1.pl line 14.
    $rr is ?<pre class='xdebug-var-dump' dir='ltr'><small>string</small> <font color='#cc0000'>'[{"sn":"44","ip":"192.168.32.15","info":"redis","env":"env-zjdev"}]'</font> <i>(length=67)</i>
    </pre>
    Wide character in print at a1.pl line 22.
    $out is ?<pre class='xdebug-var-dump' dir='ltr'><small>string</small> <font color='#cc0000'>'[{"sn":"44","ip":"192.168.32.15","info":"redis","env":"env-zjdev"}]'</font> <i>(length=67)</i>
    </pre>
     
     
     
     
     
     
     
     
     
     
     
     
    


    
    
    
                                        
    
  • 相关阅读:
    网站抓取
    Java经典类库-Guava中的函数式编程讲解
    更快的memcpy
    Jqgrid入门-使用模态对话框编辑表格数据(三)
    深入理解.NET程序的原理 谈一谈破解.NET软件的工具和方法
    jquery跨域请求数据
    C#WebBrowser控件使用教程与技巧收集
    memcached 命令操作详解
    C#中WindowsForm常见控件的运用
    多线程实践
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350839.html
Copyright © 2020-2023  润新知