NAME
Lingua::Han::PinYin - Retrieve the Mandarin(PinYin) of Chinese character(HanZi).
SYNOPSIS
use Lingua::Han::PinYin;
my $h2p = Lingua::Han::PinYin->new();
# han2pinyin
my $pinyin = $h2p->han2pinyin("我爱你"); # woaini
my @result = $h2p->han2pinyin("爱你"); # @result = ('ai', 'ni');
DESCRIPTION
Convert Mandarin to its spell
RETURN VALUE
Usually, it returns its pinyin/spell.
if not (I mean it's not a Chinese character), returns the original word.
OPTION
- tone => 1|0
-
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');
- unicode => 1|0
-
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
- capitalize => 1|0
-
default is 0, if 1, will capitalize each pinyin word
my $h2p = Lingua::Han::PinYin->new(capitalize => 1); print $h2p->han2pinyin("汉语拼音"); # HanYuPinYin
METHODS
- han2pinyin
-
print $h2p->han2pinyin("林道"); #lin2dao4 print $h2p->han2pinyin("I love 余瑞华 a"); #i love yuruihua a
- han2pinyin1
-
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
- gb2pinyin
-
if you are sure your encoding is GB2312, gb2pinyin is faster
print $h2p->gb2pinyin("I love (汉语)拼―音 Ah"); # I love (hanyu)pin―yin Ah
SEE ALSO
AUTHORS
Fayland Lam, <fayland at gmail.com>
Tong Sun, <suntong at cpan.org>
COPYRIGHT
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.