Skip to content

Commit acc3827

Browse files
committed
Fix writting string #24
1 parent e58ecba commit acc3827

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

SharpIpp/Protocol/IppProtocol.Attributes.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ private Resolution ReadResolution(BinaryReader stream)
174174

175175
public void Write(string value, BinaryWriter stream, Encoding? encoding)
176176
{
177-
stream.WriteBigEndian((short)value.Length);
178-
stream.Write((encoding ?? Encoding.ASCII).GetBytes(value));
177+
var bytes = (encoding ?? Encoding.ASCII).GetBytes(value);
178+
stream.WriteBigEndian((short)bytes.Length);
179+
stream.Write(bytes);
179180
}
180181

181182
private string ReadString(BinaryReader stream, Encoding? encoding = null)

0 commit comments

Comments
 (0)