/// <summary>
        /// Reads C-style string (null terminated) from the stream.
        /// </summary>
        public StringReference ReadCString()
        {
            StringReference value = BaseReader.ReadCString();
            uint            size  = (uint)value.Buffer.Bytes.Length + 1;

            if (size <= blockRemaining)
            {
                blockRemaining -= size;
                position       += size;
                CheckMoveReader();
                return(value);
            }

            // Check if we are reading from two consecutive blocks
            if (size < BlockSize * 2 && blockIndex + 1 < Blocks.Length && Blocks[blockIndex] + 1 == Blocks[blockIndex + 1])
            {
                uint secondBlockRead = size - blockRemaining;

                position += size;

                // Seek for next block
                blockIndex++;
                if (blockIndex + 1 == Blocks.Length)
                {
                    blockRemaining = (uint)(Length - position);
                }
                else
                {
                    blockRemaining = BlockSize;
                }
                blockRemaining -= secondBlockRead;
                return(value);
            }

            // Rewind and fallback to slow reader (byte per byte)
            BaseReader.Position -= size;

            List <byte> bytes = new List <byte>();
            byte        b     = ReadByte();

            while (b != 0)
            {
                bytes.Add(b);
                b = ReadByte();
            }

            MemoryBuffer buffer = new MemoryBuffer(bytes.ToArray());

            return(new StringReference(buffer, StringReference.Encoding.UTF8));
        }
        /// <summary>
        /// Reads C-style string (null terminated) from the stream.
        /// </summary>
        public string ReadCString()
        {
            long   basePosition = BaseReader.Position;
            string value        = BaseReader.ReadCString();
            uint   size         = (uint)value.Length + 1;

            if (size <= blockRemaining)
            {
                blockRemaining -= size;
                position       += size;
                CheckMoveReader();
                return(value);
            }

            // Check if we are reading from two consecutive blocks
            if (size < BlockSize * 2 && blockIndex + 1 < Blocks.Length && Blocks[blockIndex] + 1 == Blocks[blockIndex + 1])
            {
                uint secondBlockRead = size - blockRemaining;

                position += size;

                // Seek for next block
                blockIndex++;
                if (blockIndex + 1 == Blocks.Length)
                {
                    blockRemaining = (uint)(Length - position);
                }
                else
                {
                    blockRemaining = BlockSize;
                }
                blockRemaining -= secondBlockRead;
                return(value);
            }

            // Rewind and fallback to slow reader (byte per byte)
            BaseReader.Position = basePosition;

            StringBuilder sb = new StringBuilder();
            byte          b  = ReadByte();

            while (b != 0)
            {
                sb.Append((char)b);
                b = ReadByte();
            }
            return(sb.ToString());
        }