Example #1
0
 private ushort ReadUShort(Stream src)
 {
     byte[] buffer = new byte[2];
     src.Read(buffer, 0, 2);
     offset += 2;
     return((ushort)ByteUtils.ByteToUInt(buffer, 2));
 }
Example #2
0
        private string ReadString(Stream src)
        {
            byte[] bs = new byte[2];
            src.Read(bs, 0, 2);
            offset += 2;
            int n = (int)ByteUtils.ByteToUInt(bs, 2);

            bs = new byte[n];
            src.Read(bs, 0, n);
            offset += n;
            return(Encoding.UTF8.GetString(bs, 0, bs.Length));
        }
Example #3
0
        private string ReadLongString(Stream src)
        {
            byte[] bs = new byte[4];
            src.Read(bs, 0, 4);
            offset += 4;
            int n = (int)ByteUtils.ByteToUInt(bs, 4);

            bs = new byte[n];
            src.Read(bs, 0, n);
            offset += n;
            //return Encoding.ASCII.GetString(bs);
            return(Encoding.UTF8.GetString(bs, 0, bs.Length));
        }
Example #4
0
        private ScriptArray ReadStrictArray(Stream src)
        {
            byte[] bs = new byte[4];
            src.Read(bs, 0, 4);
            offset += 4;
            ScriptArray array = new ScriptArray();
            uint        count = ByteUtils.ByteToUInt(bs, 4);

            for (uint i = 0; i < count; i++)
            {
                array.Add(ReadElement(src));
            }
            return(array);
        }
Example #5
0
        private ScriptObject ReadArray(Stream src)
        {
            byte[] buffer = new byte[4];
            src.Read(buffer, 0, 4);
            offset += 4;
            uint         count = ByteUtils.ByteToUInt(buffer, 4);
            ScriptObject array = new ScriptObject();

            for (uint i = 0; i < count; i++)
            {
                string key = ReadString(src);
                array[key] = ReadElement(src);
            }
            src.Seek(3, SeekOrigin.Current); // 00 00 09
            offset += 3;
            return(array);
        }