根據漢字獲取拼音

2021-07-26 05:05:34 字數 421 閱讀 2802

前段時間因為需要對多個姓名進行排序,然後找了好幾個漢字轉拼音的方法都存在各種bug,要麼是漢字型檔太少,要麼是對於多音字無法識別。。。最終自己研究了一下gb2312的拼音庫,寫了個很簡單還算比較好用的方法貢獻給大家。

import net.sourceforge.pinyin4j.pinyinhelper;

/** * 通過漢字獲取拼音

*/public

class

chinesetospell else }}

return sb.tostring().tolowercase();

}return

null;

}}

方法很簡單,因為核心部分還是封裝好的tohanyupinyinstringarray()方法,只是簡單的使用而已,沒有繼續深入了解。。

C 獲取漢字拼音

using system using system.collections.generic using system.text using system.text.regularexpressions namespace ctr.common.tools 機內碼對應的拼音陣列 private sta...

C 獲取漢字拼音

using system using system.collections.generic using system.text using system.text.regularexpressions namespace ctr.common.tools 機內碼對應的拼音陣列 private sta...

C 獲取漢字拼音

using system using system.collections.generic using system.text using system.text.regularexpressions namespace ctr.common.tools 機內碼對應的拼音陣列 private sta...