Search for Chinese characters-----need to return the letter of each person's name on the server side
The method of extracting pinyin from Android Chinese characters J
http://blog.csdn.net/tanranran/article/details/44173471
First, Introduction
Project Address: Https://github.com/stuxuhai/jpinyin
Jpinyin is a kind of Java open source class library of Chinese characters to pinyin, and has made some improvements on the basis of pinyin4j function.
"Jpinyin Main Features"
1, accurate, perfect font;
Unicode encoding from the 4e00-9fa5 range and 3007 (0) of the 20,903 Chinese characters, Jpinyin can convert all the Chinese characters except the 46 allogeneic words (the non-standard pinyin);
2, pinyin conversion speed fast;
After testing, the conversion of Unicode encoding from the 4e00-9fa5 range of 20,902 Kanji, Jpinyin takes about 100 milliseconds.
3, multi-pinyin format output support;
Jpinyin supports a variety of pinyin output formats: bands, non-bands, digital representation of phonetic transcription, and pinyin first letter output format;
4, common polyphone recognition;
Jpinyin supports the identification of common polyphone, including phrases, idioms, place names, etc.;
5, simplified Traditional Chinese conversion
Jpinyin A total of four categories:
Chinesehelper.java Chinese Simplified and traditional conversion class
Pinyinformat.java Pinyin Format Class
Pinyinhelper.java Kanji to Pinyin class
Pinyinresource.java Resource file Load class
II. introduction of the main methods
A converttopinyinstring (string str, string separator) * Converts a string into a phonetic alphabet in the appropriate format
Public Static string converttopinyinstring (String str, string separator) Public Static String converttopinyinstring (String str, string separator, Pinyinformat Pinyinformat)
Results:
String words ="Gas Money"; Final String separator =" ";//héqìshēng cái (default format)pinyinhelper.converttopinyinstring (words, separator); Pinyinhelper.converttopinyinstring (str,",", Pinyinformat.with_tone_mark);//Nǐ,hǎo,shì,jiè//with TonesPinyinhelper.converttopinyinstring (str,",", Pinyinformat.with_tone_number);//ni3,hao3,shi4,jie4//a tone with a numberPinyinhelper.converttopinyinstring (str,",", Pinyinformat.without_tone);//Ni,hao,shi,jie
Getshortpinyin (String str) Chinese string---First letter Str
Public Static " Hello World "//
Three Converttopinyinarray (char c) Single character string---Pinyin converts a single Chinese character to the phonetic alphabet of the corresponding format
Public Static String[] Converttopinyinarray (char c)publicstatic string[] Converttopinyinarray (char" gas money "// Héhèhuóhuòhú = Pinyinhelper.converttopinyinarray (Words.tochararray () [0]);
Four Hasmultipinyin (char c) determines whether a Chinese character is polyphone true for Polyphone, otherwise returns false
Public static Boolean hasmultipinyin (char c)// falseprintln ( Pinyinhelper.hasmultipinyin (' li '));
Android--jpinyin class