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\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>
















                        
                        
                 

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



HTML::Entities 編碼或解碼 HTML 實體的字符串 在Python字符串中解碼HTML實體? - Decode HTML entities in Python string? Android字符串編碼和html實體轉換 - Android string encoding and html entities converting 解碼包含特殊HTML實體的字符串的正確方法是什么?(復制) - What's the right way to decode a string that has special HTML entities in it? [duplicate] 在Angular字符串中使用HTML實體 - Using HTML Entities within Angular strings HTML字符實體(Character Entities),轉義字符串(Escape Sequence) HTML字符實體(Character Entities),轉義字符串(Escape Sequence 如何在Ruby中編碼/解碼HTML實體? - How do I encode/decode HTML entities in Ruby? 在Python中將XML/HTML實體轉換為Unicode字符串[duplicate] - Convert XML/HTML Entities into Unicode String in Python [duplicate]
 
粤ICP备14056181号  © 2014-2020 ITdaan.com