2009/1/22 agentzh <[email protected]>

> 以字符语义编历串,如果是 ascii 则按 1 计算之(有专门的正则 group),否则算 2 不就结了?
>

For the record:

$ perl -MEncode -e 'for (split //, Encode::decode "utf8",shift) { if
(/[[:ascii:]]/) { $c++ } else { $c+=2 } }print $c' '你b好'
5

Hope this helps :)

-agentzh

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

回复