Skip to content

Commit 11d2af1

Browse files
authored
Merge pull request #35 from rocky/patch-1
tcp-api.pack_msg() computes the wrong length for multi-byte encoded messages like Chines
2 parents 2398682 + 46175ea commit 11d2af1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

trepan/inout/tcpfns.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
def pack_msg(msg):
2323
fmt = '%%0%dd' % LOG_MAX_MSG # A funny way of writing: '%04d'
24-
return bytes(( fmt % len(msg)) + msg, 'UTF-8')
24+
byte_msg = bytes(msg, 'UTF-8')
25+
byte_fmt = bytes(fmt % len(byte_msg), 'UTF-8')
26+
return byte_fmt + byte_msg
2527

2628
def unpack_msg(buf):
2729
if len(buf) == 0:

0 commit comments

Comments
 (0)