NAME

Lingua::Han::PinYin - Retrieve the Mandarin(PinYin) of Chinese character(HanZi).

SYNOPSIS

use Lingua::Han::PinYin;

my $h2p = new Lingua::Han::PinYin();

# han2pinyin
print $h2p->han2pinyin("我"); # wo
my @result = $h2p->han2pinyin("爱你"); # @result = ('ai', 'ni');

# 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

# we can set the tone up
my $h2p = new Lingua::Han::PinYin(tone => 1);
print $h2p->han2pinyin("我"); #wo3
my @result = $h2p->han2pinyin("爱你"); # @result = ('ai4', 'ni3');
print $h2p->han2pinyin("林道"); #lin2dao4
print $h2p->han2pinyin("I love 余瑞华 a"); #i love yuruihua a

# for polyphone(duoyinzi)
my $h2p = new Lingua::Han::PinYin(duoyinzi => 1, tone => 1);
print $h2p->han2pinyin("行"); # 'xing2 hang2 xing4 hang4 heng2'

DESCRIPTION

There is a Chinese document @ http://www.fayland.org/project/Han-PinYin/. It tells why and how I write this module.

RETURN VALUE

Usually, it returns its pinyin/spell. It includes more than 20,000 words (from Unicode.org Unihan.txt, version 4.1.0).

if not(I mean it's not a Chinese character), returns the original word;

OPTION

tone => 1|0

default is 0. if tone is needed, plz set this to 1.

duoyinzi => 1|0

default is 0.

CAVEAT

The ascii 'v' is used instead of the unicode 'yu' Since version 0.06.

SEE ALSO

Unicode::Unihan

AUTHORS

Fayland Lam, <fayland at gmail.com>

Tong Sun, <suntong at cpan.org>

COPYRIGHT

Copyright (c) 2005-2009 *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