7->8 Handle garbage string trash

no terminator? no problem
This commit is contained in:
Kurt 2024-05-17 13:18:48 -05:00
parent da51291364
commit f5c6510b82

View file

@ -171,7 +171,11 @@ public static class StringConverter8
{
// If a replacement is made, any leading or trailing halfwidth spaces are trimmed.
// This allows nicknames/OT names that are the empty string or consist entirely of fullwidth spaces.
var region = u16[..u16.IndexOf((char)TerminatorNull)];
int length = u16.IndexOf((char)TerminatorNull);
if (length == -1)
length = u16.Length; // Full buffer (bad input), but still remap.
var region = u16[..length];
char seek = ' ';
if (BitConverter.IsLittleEndian)
seek = (char)ReverseEndianness(' ');