Improved (?) Writer.WriteNullTerminatedString method

This commit is contained in:
Michael Becker 2015-09-08 09:12:20 -04:00
parent 9145f0cae8
commit 90dccc9578

View File

@ -179,7 +179,15 @@ namespace UniversalEditor.IO
}
public void WriteNullTerminatedString(string sz, int length)
{
this.WriteFixedLengthString(sz, length);
// TODO: not sure how to handle this, should "length" refer to just the string length (data length) or should it include the null-terminator (field length)?
string ssz = sz.Substring(0, Math.Min(sz.Length, length) - 1);
WriteNullTerminatedString(ssz);
}
public void WriteNullTerminatedString(string sz, Encoding encoding, int length)
{
// TODO: not sure how to handle this, should "length" refer to just the string length (data length) or should it include the null-terminator (field length)?
string ssz = sz.Substring(0, Math.Min(sz.Length, length) - 1);
WriteNullTerminatedString(ssz, encoding);
}
public void WriteInt16(short value)