fix: Fixes reading multiple strings (books) (#1814)

This commit is contained in:
Kamron Batman 2024-06-02 15:01:18 -07:00 committed by GitHub
parent 5f8f7982eb
commit aeba2261d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -195,11 +195,12 @@ public ref struct SpanReader
var span = _buffer.Slice(Position, size);
var index = span.IndexOfTerminator(byteLength);
span = _buffer.Slice(Position, index);
Position += isFixedLength || index < 0 ? size : index;
Position += isFixedLength || index < 0 ? size : index + 1;
// The string is either as long as the first terminator character, remaining buffer size, or fixed length.
return TextEncoding.GetString(span[..(index < 0 ? size : index)], encoding, safeString);
return TextEncoding.GetString(span, encoding, safeString);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]