前段時間因為需要對多個姓名進行排序,然後找了好幾個漢字轉拼音的方法都存在各種bug,要麼是漢字型檔太少,要麼是對於多音字無法識別。。。最終自己研究了一下gb2312的拼音庫,寫了個很簡單還算比較好用的方法貢獻給大家。
方法很簡單,因為核心部分還是封裝好的tohanyupinyinstringarray()方法,只是簡單的使用而已,沒有繼續深入了解。。import net.sourceforge.pinyin4j.pinyinhelper;
/** * 通過漢字獲取拼音
*/public
class
chinesetospell else }}
return sb.tostring().tolowercase();
}return
null;
}}
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...