private ushort ReadUShort(Stream src) { byte[] buffer = new byte[2]; src.Read(buffer, 0, 2); offset += 2; return((ushort)ByteUtils.ByteToUInt(buffer, 2)); }
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)); }
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)); }
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); }
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); }