Conversion of Chinese characters from java to Pinyin and conversion of Chinese characters from java to PinYin

Source: Internet
Author: User

Conversion of Chinese characters from java to Pinyin and conversion of Chinese characters from java to PinYin

Original: java Chinese Character converted to PinYin code: http://www.zuidaima.com/share/1550463275240448.htm

Conversion of Chinese characters from java to PinYin

The input string is: "This is a Chinese character"

Running result:

 



How to input Chinese Characters in java and convert them into pinyin? Guidance

This is what I have done in my project and I hope it will help you.

Public class CharacterParser {
Private static int [] pyvalue = new int [] {-20319,-20317,-20304,-20295,
-20292,-20283,-20265,-20257,-20242,-20230,-20051,-20036,
-20032,-20026,-20002,-19990,-19986,-19982,-19976,-19805,
-19784,-19775,-19774,-19763,-19756,-19751,-19746,-19741,
-19739,-19728,-19725,-19715,-19540,-19531,-19525,-19515,
-19500,-19484,-19479,-19467,-19289,-19288,-19281,-19275,
-19270,-19263,-19261,-19249,-19243,-19242,-19238,-19235,
-19227,-19224,-19218,-19212,-19038,-19023,-19018,-19006,
-19003,-18996,-18977,-18961,-18952,-18783,-18774,-18773,
-18763,-18756,-18741,-18735,-18731,-18722,-18710,-18697,
-18696,-18526,-18518,-18501,-18490,-18478,-18463,-18448,
-18447,-18446,-18239,-18237,-18231,-18220,-18211,-18201,
-18184,-18183,-18181,-18012,-17997,-17988,-17970,-17964,
-17961,-17950,-17947,-17931,-17928,-17922,-17759,-17752,
-17733,-17730,-17721,-17703,-17701,-17697,-17692,-17683,
-17676,-17496,-17487,-17482,-17468,-17454,-17433,-17427,
-17417,-17202,-17185,-16983,-16970,-16942,-16915,-16733,
-16708,-16706,-16689,-16664,-16657,-16647,-16474,-16470,
-16465,-16459,-16452,-16448,-16433,-16429,-16427,-16423,
-16419,-16412,-16407,-16403,-16401,-16393,-16220,-16216,
-16212,-16205,-16202,-16187,-16180,-16171,-16169,-16158,
-16155,-15959,-15958,-...... remaining full text>

How does java convert Chinese characters to PinYin?

Char [] ch = "Chinese character". toCharArray ();
String [] pinyinHead = PinyinHelper. toHanyuPinyinStringArray (ch [0]);

You need a pinyin4j. jar file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.