<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\npapier-mâché résumé";
print encode_entities($input), "\n"
描述:
该模块处理字符串的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\n";
}
else {
die $response->status_line;
};
$out=decode_entities($rr);
print "\$out is $out\n";
[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>