internal static PinyinUnit Deserialize(BinaryReader binaryReader, StringBuilder sb) { PinyinUnit pinyinUnit = new PinyinUnit(); byte[] bytes = binaryReader.ReadBytes(7); pinyinUnit.Pinyin = Encoding.ASCII.GetString(bytes, 0, 7); char[] chArray = new char[1]; pinyinUnit.Pinyin = pinyinUnit.Pinyin.TrimEnd(chArray); sb.AppendLine(string.Format("{0}", pinyinUnit.Pinyin)); return(pinyinUnit); }
internal static PinyinDictionary Deserialize(BinaryReader binaryReader) {//文件18个字节后的为正常可解析部分【按7个长度依次类推】 binaryReader.ReadBytes(18); PinyinDictionary pinyinDictionary = new PinyinDictionary(); //var gg= binaryReader.ReadBytes(14); pinyinDictionary.Length = binaryReader.ReadInt16(); pinyinDictionary.Count = binaryReader.ReadInt16(); pinyinDictionary.Offset = binaryReader.ReadInt16(); binaryReader.ReadBytes(8); pinyinDictionary.PinyinUnitTable = new List <PinyinUnit>(); StringBuilder sb = new StringBuilder(); for (int index = 0; index < (int)pinyinDictionary.Count; ++index) { pinyinDictionary.PinyinUnitTable.Add(PinyinUnit.Deserialize(binaryReader, sb)); } int num = (int)binaryReader.ReadInt16(); File.WriteAllText("PinyinDictionary.txt", sb.ToString(), Encoding.UTF8); return(pinyinDictionary); }