转成unicode以后用property匹配,例(设输入输出编码为gb2312、gbk或gb18030):
use Encode;
$_="abc你好wert";
$a=decode('cp936',$_);
($x)=($a=~m/(\p{Han}+)/);
print encode('cp936',$x),"\n";
use Encode;
$_="abc你好wert";
$a=decode('cp936',$_);
($x)=($a=~m/(\p{Han}+)/);
print encode('cp936',$x),"\n";
博客介绍了在Perl中,将输入输出编码设为gb2312、gbk或gb18030后,转成unicode用property匹配的方法,并给出示例代码,通过decode和encode函数处理编码,使用正则表达式匹配中文。
608

被折叠的 条评论
为什么被折叠?



