internal static void ResourceToTxt(string strTxtFile) { using (FileStream fileStream = new FileStream(strTxtFile, FileMode.Create, FileAccess.Write)) { using (StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.UTF8)) { streamWriter.Write(ChinesePinyin.charDictionary.Count); streamWriter.WriteLine(""); for (int index = 0; index < ChinesePinyin.charDictionary.Count; index++) { CharUnit charUnit = ChinesePinyin.charDictionary.CharUnitTable[index]; streamWriter.Write(charUnit.Char); streamWriter.Write(" "); streamWriter.Write((int)charUnit.m_strokeNumber); streamWriter.Write(" "); streamWriter.Write((int)charUnit.m_pinyinCount); for (int index2 = 0; index2 < (int)charUnit.m_pinyinCount; index2++) { PinyinUnit pinYinUnitByIndex = ChinesePinyin.pinyinDictionary.GetPinYinUnitByIndex((int)charUnit.PinyinIndexList[index2]); streamWriter.Write(" "); streamWriter.Write(pinYinUnitByIndex.Pinyin); } streamWriter.WriteLine(""); } } } }
internal static CharUnit Deserialize(BinaryReader binaryReader) { CharUnit unit = new CharUnit(); unit.Char = binaryReader.ReadChar(); unit.m_strokeNumber = binaryReader.ReadByte(); unit.m_pinyinCount = binaryReader.ReadByte(); unit.PinyinIndexList = new short[(int)unit.m_pinyinCount]; for (int i = 0; i < (int)unit.m_pinyinCount; i++) { unit.PinyinIndexList[i] = binaryReader.ReadInt16(); } return(unit); }
internal static CharDictionary Deserialize(BinaryReader binaryReader) { CharDictionary dictionary = new CharDictionary(); binaryReader.ReadInt32(); dictionary.Length = binaryReader.ReadInt32(); dictionary.Count = binaryReader.ReadInt32(); dictionary.Offset = binaryReader.ReadInt16(); binaryReader.ReadBytes(24); dictionary.CharUnitTable = new List <CharUnit>(); for (int i = 0; i < dictionary.Count; i++) { dictionary.CharUnitTable.Add(CharUnit.Deserialize(binaryReader)); } binaryReader.ReadInt16(); return(dictionary); }
internal bool Match(CharUnit charUnit) { return(charUnit.Char == this.ExpectedChar); }
private void DoConvertToPinyin() { StringBuilder stringBuilder = new StringBuilder(); List <char> list = new List <char>(); List <string> list2 = new List <string>(); this.ClearResult(); for (int index = 0; index < this.m_chineseString.Length; index++) { char index2 = this.m_chineseString[index]; string str = ""; char ch = '\0'; bool flag = false; bool flag2 = false; list2.Clear(); bool flag3 = ChinesePinyin.IsChineseLetter(index2); if (flag3) { bool flag4 = index == 0; if (flag4) { this.m_chineseCharacter = index2; } CharUnit charUnit = ChinesePinyin.charDictionary.GetCharUnit(index2); bool flag5 = charUnit != null; if (flag5) { int num = (int)charUnit.m_pinyinCount; PinyinUnit pinYinUnitByIndex = ChinesePinyin.pinyinDictionary.GetPinYinUnitByIndex((int)charUnit.PinyinIndexList[0]); bool flag6 = pinYinUnitByIndex != null; if (flag6) { str = pinYinUnitByIndex.Pinyin.Substring(0, pinYinUnitByIndex.Pinyin.Length - 1).ToLower(); ch = pinYinUnitByIndex.Pinyin[0]; list2.Add(str); bool flag7 = index == 0; if (flag7) { this.m_strokeNumber = (short)charUnit.m_strokeNumber; this.m_pinyinCount = (short)charUnit.m_pinyinCount; this.m_isPolyphone = (this.m_pinyinCount > 1); this.m_pinyinList[0] = pinYinUnitByIndex.Pinyin.ToLower(); } } for (int index3 = 1; index3 < num; index3++) { PinyinUnit pinYinUnitByIndex2 = ChinesePinyin.pinyinDictionary.GetPinYinUnitByIndex((int)charUnit.PinyinIndexList[index3]); bool flag8 = pinYinUnitByIndex2 != null; if (flag8) { string str2 = pinYinUnitByIndex2.Pinyin.ToLower(); bool flag9 = index == 0; if (flag9) { this.m_pinyinList[index3] = str2; } string str3 = str2.Substring(0, str2.Length - 1); bool flag10 = !list2.Contains(str3); if (flag10) { list2.Add(str3); flag = true; bool flag11 = ch != pinYinUnitByIndex2.Pinyin[0]; if (flag11) { flag2 = true; } } } } } } else { str = index2.ToString(); ch = index2; } bool flag12 = ChinesePinyin.pinyinCustom.ContainsKey(index2); if (flag12) { string str4 = ChinesePinyin.pinyinCustom[index2]; str = str4.ToLower(); bool flag13 = str4.Length > 0; if (flag13) { ch = str4[0]; } } bool flag14 = str != ""; if (flag14) { stringBuilder.Append(str); this.m_strShouZiMu += ch.ToString(); bool flag15 = flag && !list.Contains(index2); if (flag15) { list.Add(index2); string str5 = ""; for (int index4 = 0; index4 < list2.Count; index4++) { bool flag16 = str5 != ""; if (flag16) { str5 += " "; } str5 += list2[index4]; } this.m_strPolyphone1 = string.Concat(new string[] { this.m_strPolyphone1, index2.ToString(), "(", str5, ")" }); bool flag17 = flag2; if (flag17) { this.m_strPolyphone2 = string.Concat(new string[] { this.m_strPolyphone2, index2.ToString(), "(", str5, ")" }); } } } else { this.m_unknownChars += index2.ToString(); bool flag18 = this.m_unknownFill != ""; if (flag18) { stringBuilder.Append(this.m_unknownFill); this.m_strShouZiMu += this.m_unknownFill; } else { stringBuilder.Append(index2); this.m_strShouZiMu += index2.ToString(); } } } this.m_strPinYin = stringBuilder.ToString(); }