2009年7月7日星期二

[PerlChina] Re: 解析HTML entities

怎么不行?
decode_entities 是 HTML::Entities 默认导入的函数,你只要:

use HTML::Entities;
$str = '數度';
$str_decoded =  decode_entities($str);

这时 $str_decoded 里面的就是你要的 unicode 字符了啊。
如果你的环境是 utf8 的,那么:

use Encode;
print encode_utf8 $str_decoded;

就可以正确打印出你要的字符 "數度" 了。

2009/7/7 Question <wanliyou@gmail.com>
Hi.

类似这样的HTML entities 在perl里怎么解?
&#63849;&#64001;

HTML::Entities qw(decode_entities)
这个似乎不行.

--
>: ~




--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
 要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
 要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛

-~----------~----~----~----~------~----~------~--~---

没有评论: