Commit 750e65d8 authored by Alexander Korolkov's avatar Alexander Korolkov

Fix string length in pack_string()

Specification says that strings are encoded as sequences of UTF-8
characters preceded by length in bytes. But the length was calculated
as a number of UTF-8 characters. So packing of strings with
non-ASCII characters was broken.
parent 549ec004
......@@ -155,6 +155,7 @@ def pack_string(string):
return struct.pack("<i", -1)
if not isinstance(string, bytes):
string = string.encode()
length = len(string)
return struct.pack("<i", length) + string
pack_bytes = pack_string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment