ReadString0 does not read 0-terminator correctly
Not found in the tests due to how strings are written there, the SpanReader.ReadString0
method does not correctly skip over the 0 terminator in multi-byte encodings.
To be exact, it misses skipping terminatorSize - 1
bytes, which most noticeably breaks UTF16 strings (failing to decode the last character and ending in a position one byte too early).
The traditional BinaryData
library does not have this issue as it uses old code to decode strings. It needs to be fixed in the Memory
library only.
This breaks existing code having written strings with SpanWriter.WriteString0
and a multi-byte encoding.