exxeleron / qPython

interprocess communication between Python and kdb+
http://www.devnet.de
Apache License 2.0
152 stars 89 forks source link

Correctly calculate message length based on encoded length #77

Open atf1206 opened 3 years ago

atf1206 commented 3 years ago

The current implementation calculates the length of the string to send by simply using len() on the string. However, the correct calculation (that kdb expects) is the length of the encoded string.

In latin-1 and ascii, these two are the same. However for extended characters such as those in the utf-8 char-set, a single character in a python string may be 2 or more encoded characters. Since QConnection now supports passing alternate encoding parameters, e.g. utf-8, this should be supported here as well -- otherwise qPython reports an error when trying to send extended chars.