Fix issues with NULL char not being treated properly (Thanks tornato)

This commit is contained in:
UnknownShadow200 2017-11-25 16:37:18 +11:00
parent 33c20d26fc
commit 2512479689

View File

@ -72,8 +72,9 @@ namespace MCGalaxy {
char* characters = stackalloc char[StringSize];
for (int i = StringSize - 1; i >= 0; i--) {
byte code = data[i + offset];
if( length == 0 && !(code == 0x00 || code == 0x20))
length = i + 1;
if (code == 0) code = 0x20; // NULL to space
if (length == 0 && code != 0x20) { length = i + 1; }
characters[i] = ((char)code).Cp437ToUnicode();
}
return new String(characters, 0, length);