3 ms·
How is the string length determined? How does this handle packed bits/ and odd sized numbers, for example a 5 bit digit and 3 flags
by jbverschoor 2y ago
How is the string length determined?
How does this handle packed bits/ and odd sized numbers, for example a 5 bit digit and 3 flags
- rangerelf 2y agoI think that would be up to you; just use a union struct with that data and send/receive the corresponding int.
- edflsafoiewq 2y agoStrings are serialized as (type code) (uint16 length) (string contents) (null byte). In the API, the string length is determined the normal way in each language: strlen() in C, len() in Python. The trailing NUL allows the C decoder to return just a pointer to the string (without allocating). So internal null bytes and strings longer than 0xFFFF are functionally prohibited.