コード例 #1
0
ファイル: ReadPinYin.cs プロジェクト: suwushuN/Tools
        internal static CharUnit Deserialize(BinaryReader binaryReader, StringBuilder sb)
        {
            CharUnit charUnit = new CharUnit()
            {
                Char         = binaryReader.ReadChar(),
                StrokeNumber = binaryReader.ReadByte(),
                PinyinCount  = binaryReader.ReadByte()
            };

            sb.Append(string.Format("{0},{1},{2},", charUnit.Char, charUnit.StrokeNumber, charUnit.PinyinCount));
            charUnit.PinyinIndexList = new short[(int)charUnit.PinyinCount];
            for (int index = 0; index < (int)charUnit.PinyinCount; ++index)
            {
                charUnit.PinyinIndexList[index] = binaryReader.ReadInt16();
                sb.Append(charUnit.PinyinIndexList[index]).Append(",");
            }
            sb.Append(System.Environment.NewLine);
            return(charUnit);
        }
コード例 #2
0
ファイル: ReadPinYin.cs プロジェクト: suwushuN/Tools
        internal static CharDictionary Deserialize(BinaryReader binaryReader)
        {
            StringBuilder  sb             = new StringBuilder();
            CharDictionary charDictionary = new CharDictionary();

            // binaryReader.ReadInt32();
            charDictionary.Length = binaryReader.ReadInt32();
            charDictionary.Count  = binaryReader.ReadInt32();
            charDictionary.Offset = binaryReader.ReadInt16();
            binaryReader.ReadBytes(24);
            charDictionary.CharUnitTable = new List <CharUnit>();
            for (int index = 0; index < charDictionary.Count; ++index)
            {
                charDictionary.CharUnitTable.Add(CharUnit.Deserialize(binaryReader, sb));
            }
            int num = (int)binaryReader.ReadInt16();

            File.WriteAllText("charDict.txt", sb.ToString(), Encoding.UTF8);
            return(charDictionary);
        }