Пример #1
0
        public static string ReadCountedUtf8(this BufferedBinaryReader reader)
        {
            int b0 = reader.ReadUInt8();

            if (b0 == 0xFF)
            {
                return(null);
            }
            if (b0 == 0)
            {
                return(string.Empty);
            }
            int len = reader.ReadPackedInt(b0);

            return(reader.ReadUtf8(len));
        }
Пример #2
0
        public string Fetch(uint offset)
        {
            if (offset >= _heap.Length)
            {
                throw new BadMetadataException("Invalid #Strings heap index.");
            }

            string value;

            if (_cache.TryGetValue(offset, out value))
            {
                return(value);
            }

            _heap.Seek(offset, SeekOrigin.Begin);

            value = _heap.ReadUtf8();
            _cache.Add(offset, value);

            return(value);
        }