示例#1
0
文件: ctdb.cs 项目: HappyASR/pujia
        public static void Export(string input)
        {
            StreamEx s = new StreamEx(input, System.IO.FileMode.Open, System.IO.FileAccess.Read);

            // txt count
            s.Position = 0x0e;
            UInt16 txtCount = s.ReadUInt16BigEndian();

            // section offset
            s.Position = 0x10;
            Int32 sec1Offset = s.ReadInt32BigEndian();
            Int32 sec2Offset = s.ReadInt32BigEndian();
            Int32 sec3Offset = s.ReadInt32BigEndian();

            // get text offset
            s.Position = sec1Offset;
            UInt16[] txtOffset = new UInt16[txtCount + 1];
            for (int i = 0; i < txtCount; i++)
            {
                s.Position  += 6;
                txtOffset[i] = s.ReadUInt16BigEndian();
            }
            txtOffset[txtCount] = (UInt16)s.Length;

            // get text
            string[] txtVal = new string[txtCount];
            for (int i = 0; i < txtCount; i++)
            {
                s.Position = txtOffset[i];
                txtVal[i]  = s.ReadStringWithNull(txtOffset[i + 1] - txtOffset[i] - 2, Encoding.BigEndianUnicode);

                for (int k = 0; k < _convertChar.Count; k++)
                {
                    txtVal[i] = txtVal[i].Replace(_convertChar[k].Key, _convertChar[k].Value);
                }
            }

            Agemo.WriteFile(input + ".txt", _agemoEncoding, from txt in txtVal select txt + "{END}");
        }
示例#2
0
文件: cod.cs 项目: HappyASR/pujia
        public static bool ExportFont(string input, string refinput)
        {
            StreamEx sOri = new StreamEx(input, System.IO.FileMode.Open, System.IO.FileAccess.Read);

            List <UInt16> originChars = new List <UInt16>();

            while (sOri.Position < sOri.Length)
            {
                originChars.Add(sOri.ReadUInt16BigEndian());
                sOri.Position += 6;
            }
            sOri.Close();

            // load ref file
            StreamEx sRef = new StreamEx(refinput, System.IO.FileMode.Open, System.IO.FileAccess.Read);

            if (sRef.Length < 2)
            {
                return(false);
            }
            byte xff = sRef.ReadByte();
            byte xfe = sRef.ReadByte();

            if (xff != 0xff || xfe != 0xfe)
            {
                return(false);
            }
            while (sRef.Position < sRef.Length)
            {
                UInt16 c = sRef.ReadUInt16();
                if (!originChars.Contains(c))
                {
                    // add not already exist char
                    originChars.Add(c);
                }
            }
            sRef.Close();

            StreamEx sExp = new StreamEx(input + ".txt", System.IO.FileMode.Create, System.IO.FileAccess.Write);

            sExp.WriteByte(0xff);
            sExp.WriteByte(0xfe);
            foreach (UInt16 c in originChars)
            {
                sExp.WriteUInt16(c);
            }

            sExp.Close();

            return(true);
        }