You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unicode encoding has 2 bytes for each character but StringTerminator is only one byte. So when we serialize a string like "sdf" it will be in hex "730064006600" and if we add null terminator we need to get "730064006600"+"0000" but for now it is "730064006600"+"00" ValueValueNode.cs line ~230 all code bellow only for demonstrating direction, it is not solution
for the test i change it to
var stringTerminatorData = GetFieldEncoding()
.GetBytes(new char[] { (char)TypeNode.StringTerminator });
And little about deserialize: hex "730064006600" will be deserialized like 3 different string with one letter ValueValueNode.cs line ~891
for the test i changed the method to
private static byte[] ReadTerminated(BinaryReader reader, FieldLength maxLength,
byte terminator, Encoding enc)
{
var buffer = new MemoryStream();
var byteLength = maxLength.ByteCount;
char b;
while (byteLength-- > 0 && (b = reader.ReadChar()) != (char)terminator)
{
byte[] arr = enc.GetBytes(new char[] { b });
buffer.Write(arr, 0, arr.Length);
}
return buffer.ToArray();
}
and do not forget pass Encoding
Sorry for my english and writing style.
The text was updated successfully, but these errors were encountered:
unicode encoding has 2 bytes for each character but StringTerminator is only one byte. So when we serialize a string like "sdf" it will be in hex "730064006600" and if we add null terminator we need to get "730064006600"+"0000" but for now it is "730064006600"+"00"
ValueValueNode.cs line ~230
all code bellow only for demonstrating direction, it is not solution
for the test i change it to
And little about deserialize: hex "730064006600" will be deserialized like 3 different string with one letter
ValueValueNode.cs line ~891
for the test i changed the method to
and do not forget pass Encoding
Sorry for my english and writing style.
The text was updated successfully, but these errors were encountered: