JAVA漢字轉拼音

2021-08-23 13:57:48 字數 1327 閱讀 4462

工作原因,需要將中文轉成拼音放置到資料庫的字段中,以供搜尋使用.下面放上**以及說明.

見面是具體**:

mport net.sourceforge.pinyin4j.pinyinhelper; import net.sourceforge.pinyin4j.format.*; import net.sourceforge.pinyin4j.format.exception.*; public class hz2py `������bb^��ba��a]az����z��z).***")); } public static string topinyin(string hanzhis) ", "") .replaceall("\\|", "").replaceall("\\?", "").replaceall("\\*", "").replaceall("\\��", "").replaceall("\\��", "") .replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "") .replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "") .replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "") .replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "").replaceall("\\��", "") .replaceall("\\��", "").replaceall("\\��", "") ; system.out.println(hanzhis); charsequence s= hanzhis; char hanzhi=new char[s.length()]; for(int i=0;it3.setcasetype(hanyupinyincasetype.uppercase);

t3.settonetype(hanyupinyintonetype.without_tone);

t3.setvchartype(hanyupinyinvchartype.with_v);

可以設定轉換後拼音的大小寫,字型等.

Java把漢字轉拼音

pingyin4j.jar 漢字轉換位漢語拼音,英文本元不變 author xuke public class cn2spell catch badhanyupinyinoutputformatcombination e else return pinyinname 漢字轉換位漢語拼音,英文本元不變...

漢字轉拼音

region 漢字轉拼音 漢字轉拼音類 用法 crazycoderpinyin.covent 漢字 長度 using system.text.regularexpressions build date 20030610 public class crazycoderpinyin 定義陣列 priva...

漢字轉拼音

工具pinyin4j 2.5.0.jar 整理了3個方法,1.漢字轉拼音 2.返回中文姓 中文名 英文姓 last name 英文名 first name 3.返回首字母 public class pinyin4jdemo char hanzi word.tochararray string t2 ...