internal static PinyinUnit Deserialize(BinaryReader binaryReader) { PinyinUnit unit = new PinyinUnit(); byte[] bytes = binaryReader.ReadBytes(7); unit.Pinyin = Encoding.ASCII.GetString(bytes, 0, 7); char[] trimChars = new char[1]; unit.Pinyin = unit.Pinyin.TrimEnd(trimChars); return(unit); }
internal static PinyinDictionary Deserialize(BinaryReader binaryReader) { PinyinDictionary dictionary = new PinyinDictionary(); binaryReader.ReadInt32(); dictionary.Length = binaryReader.ReadInt16(); dictionary.Count = binaryReader.ReadInt16(); dictionary.Offset = binaryReader.ReadInt16(); binaryReader.ReadBytes(8); dictionary.PinyinUnitTable = new List <PinyinUnit>(); for (int i = 0; i < dictionary.Count; i++) { dictionary.PinyinUnitTable.Add(PinyinUnit.Deserialize(binaryReader)); } binaryReader.ReadInt16(); return(dictionary); }
/// <summary> /// ChineseChar类的构造函数。 /// </summary> /// <param name="ch">指定的汉字字符。</param> /// <exception cref="T:System.NotSupportedException"> /// 字符不在简体中文扩展字符集中。 /// </exception> /// <remarks> /// 请参阅<see cref="T:iPortal.Converter.PinYinConverter.ChineseChar" />来查看使用ChineseChar的实例。 /// </remarks> public ChineseChar(char ch) { if (!IsValidChar(ch)) { throw new NotSupportedException(AssemblyResource.CHARACTER_NOT_SUPPORTED); } this.chineseCharacter = ch; CharUnit charUnit = charDictionary.GetCharUnit(ch); this.strokeNumber = charUnit.StrokeNumber; this.pinyinCount = charUnit.PinyinCount; this.isPolyphone = charUnit.PinyinCount > 1; for (int i = 0; i < this.pinyinCount; i++) { PinyinUnit pinYinUnitByIndex = pinyinDictionary.GetPinYinUnitByIndex(charUnit.PinyinIndexList[i]); this.pinyinList[i] = pinYinUnitByIndex.Pinyin; } }
internal bool Match(PinyinUnit pinyinUnit) { return(string.Compare(pinyinUnit.Pinyin, this.ExpectedPinyin, true, CultureInfo.CurrentCulture) == 0); }