private string GetMultPinyin(string text, int index, string pinyin) { string unicode; int hexCode, charIndex; string[] charCodes, charContext, pinyinStr; PinyinMultiple number; for (int i = 2; i <= 4; i++) { charContext = ChineseCharIndex.GetCharContext(text, index, i); if (charContext.Length > 0) { number = (PinyinMultiple)Enum.Parse(typeof(PinyinMultiple), i.ToString()); unicode = GetCharUnicode(text[index]); hexCode = Convert.ToInt32(unicode, 16); charIndex = ChineseCharIndex.GetCharIndex(CharSetMultiple.OneCharSet.CharCodes, hexCode); charCodes = ChineseCharSet.GetMultCharSet(number, charIndex); if (charCodes.Length > 0) { pinyinStr = MultPinyinMatch(charContext, charCodes); if (pinyinStr.Length == 1) { return(pinyinStr[0]); } } } } return(pinyin); }
private string FindPinyin(char word) { if (IsChinese(word)) { string unicode = GetCharUnicode(word); string firstChar = unicode.Substring(0, 1); PinyinSingle number = (PinyinSingle)Enum.Parse(typeof(PinyinSingle), firstChar); int[] charCodes = ChineseCharSet.GetCharCodes(number); if (charCodes.Length > 0) { int hexCode = Convert.ToInt32(unicode, 16); int index = ChineseCharIndex.GetCharIndex(charCodes, hexCode); if (index >= 0) { string[] pinyin = ChineseCharSet.GetCharPinyin(number); if (pinyin.Length > 0) { return(pinyin[index]); } } } } return(word.ToString()); }