Fix string properties

This commit is contained in:
Jarrod Doyle 2024-08-31 11:59:34 +01:00
parent 5d23f87359
commit 047c2a1305
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 8 additions and 1 deletions

View File

@ -96,11 +96,18 @@ public class PropRenderType : Property
public class PropString : Property public class PropString : Property
{ {
public int stringLength;
public string value; public string value;
public override void Read(BinaryReader reader) public override void Read(BinaryReader reader)
{ {
base.Read(reader); base.Read(reader);
value = Encoding.UTF8.GetString(reader.ReadBytes(length)).Replace("\0", string.Empty); stringLength = reader.ReadInt32();
var tmpName = Encoding.UTF8.GetString(reader.ReadBytes(stringLength));
var idx = tmpName.IndexOf('\0');
if (idx >= 0) tmpName = tmpName[..idx];
value = tmpName;
// var tmpName = Encoding.UTF8.GetString(reader.ReadBytes(length)).Replace("\0", string.Empty);
// value = tmpName[..Math.Min(length - 1, tmpName.Length)];
} }
} }