加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

转utf-16格式的码表至utf-8,perl脚本

发布时间:2020-12-15 20:53:41 所属栏目:大数据 来源:网络整理
导读:#!/usr/bin/perl -w use strict; my %key_char; open(F2,':encoding(utf-8)',"zhengma_table_2.txt"); open(F,':encoding(utf-16)',"zhengma_table.txt"); while(F){ ?? ?if(m/^([^a-z ]*)(.*)$/){ my $char=$1; my $key=$2; my @key=split (//s+/,$key); fo

#!/usr/bin/perl -w

use strict;

my %key_char;

open(F2,'>:encoding(utf-8)',"zhengma_table_2.txt");

open(F,'<:encoding(utf-16)',"zhengma_table.txt");

while(<F>){

?? ?if(m/^([^a-z ]*)(.*)$/){

my $char=$1;

my $key=$2;

my @key=split (//s+/,$key);

foreach my $k(@key){

? ?print F2 "$k $char/n";

}

?? ?}

?? ?else{print "cannot match at $./n";}

}

close(F);

close(F2);

?

输入:

一a av

一下aa

万无一失aaam

输出:

a 一

av 一

aa 一下

aaam 万无一失

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读