Lingua::Han::PinYin - Retrieve the Mandarin(PinYin) of Chinese character(HanZi).
use Lingua::Han::PinYin; my $h2p = Lingua::Han::PinYin->new(); # han2pinyin my $pinyin = $h2p->han2pinyin("我爱你"); # woaini my @result = $h2p->han2pinyin("爱你"); # @result = ('ai', 'ni');
Convert Mandarin to its spell
Usually, it returns its pinyin/spell.
if not (I mean it's not a Chinese character), returns the original word.
default is 0. if 1, return kua4 instead of kua
my $h2p = Lingua::Han::PinYin->new(tone => 1); print $h2p->han2pinyin("我"); #wo3 my @result = $h2p->han2pinyin("爱你"); # @result = ('ai4', 'ni3');
default is 0, if 1, return kuà instead of kua4 OR kua
my $h2p = Lingua::Han::PinYin->new(unicode => 1); print $h2p->han2pinyin("叶问"); # yèwèn
default is 0, if 1, will capitalize each pinyin word
my $h2p = Lingua::Han::PinYin->new(capitalize => 1); print $h2p->han2pinyin("汉语拼音"); # HanYuPinYin
print $h2p->han2pinyin("林道"); #lin2dao4 print $h2p->han2pinyin("I love 余瑞华 a"); #i love yuruihua a
for 1 chinese letter at a time, han2pinyin1 is faster
# if you are sure to pass 1 Chinese letter at a time, han2pinyin1 is faster print $h2p->han2pinyin1("我"); # wo
if you are sure your encoding is GB2312, gb2pinyin is faster
print $h2p->gb2pinyin("I love (汉语)拼―音 Ah"); # I love (hanyu)pin―yin Ah
Unicode::Unihan
Fayland Lam, <fayland at gmail.com>
<fayland at gmail.com>
Tong Sun, <suntong at cpan.org>
<suntong at cpan.org>
Copyright (c) 2005-2012 *AUTHORS* All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install Lingua::Han::PinYin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::Han::PinYin
CPAN shell
perl -MCPAN -e shell install Lingua::Han::PinYin
For more information on module installation, please visit the detailed CPAN module installation guide.