No1 输出文件名包含汉字的脚本#暂时不用
#!/usr/bin/perl -w
use strict;
use utf8;
open(FH, "<:encoding(utf8)","a.txt") or die $!;
open(OFH, ">:encoding(utf8)", "a汉字.txt") or die $!;
my @strs=<FH>;
foreach (@strs){
if ($_=~s/^\s+$//g) {
print OFH $_;
}else{print OFH $_;}
}
close OFH;
close FH;
No.2 处理汉字字符串
#!/usr/bin/perl -w
use strict;
use Encode;
my $dat="这是一个测试文本";
my $str=decode("gb2312",$dat);
my @chars=split //,$str;
foreach (@chars) {
print encode("gb2312",$_),"\n";
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。