








#!/usr/bin/perl
# 入力はEUC-JPのTSVで住所とその読み仮名(カタカナ)。
# 出力はUTF-8のTSVで住所とその読み仮名(カタカナ+ひらがな)。
use strict;
use warnings;
use Unicode::Japanese;
while(<>) {
chomp;
my @col = split("\t", $_);
my $addr_str = Unicode::Japanese->new($col[0], 'euc-jp')->get;
my $yomi = Unicode::Japanese->new($col[1], 'euc-jp');
my $kata_str = $yomi->get;
my $hira_str = $yomi->kata2hira->get;
print "$addr_str\t$kata_str\t$hira_str\n";
}
Unicode 文字列にして、普通に tr/// でやればいいような。なるなる。
#!/usr/bin/perl use strict; use warnings; use utf8; binmode STDOUT => ":utf8";my $str = "ョヮィ・シックス・アパート"; $str =~ tr/ァ-ン/ぁ-ん/; print $str,"\n";
2006年08月08日 kitsううう、「う゛」が一文字になったやつ(\xE3\x82\x94)が入力できません
use Jcode; use utf8; jcode($str)->tr('ぁ-?', 'ァ-ヴ'); を考えました。