I have define my protobuf message that is serialize in CPP and send to Python program thank to a wrapper. On CPP side, the protobuf message is generate as std::string
Here is how I generate in cpp my message:
.... std::string data = results.SerializeAsString(); return data;In Python, I just connect my CPP wrapper and I try to get the string message. With a common message, the communication between CPP and Python works properly but with the protobuf serialized message, I get that error:
'utf-8' codec can't decode byte 0xff in position 13: invalid start byteIs there a way to encore in CPP the string message to be readable in Python?
- 1Protobuf uses
UTF-8encoding to pass strings. So if your string contains0xffand it is not BOM in front of it it is invalid UTF-8 encoding. So sender side had to use string which is not UTF-8 encoded. You should show code which writes some string value into class generated protobuf.Marek R– Marek R2024-01-23 15:34:15 +00:00CommentedJan 23, 2024 at 15:34 - Just to clarify
std::string data = results.SerializeAsString();is not related to your problem.Marek R– Marek R2024-01-23 15:42:10 +00:00CommentedJan 23, 2024 at 15:42 - You need to show the python code. More specifically, why are you trying to decode binary data as utf8?Botje– Botje2024-01-24 09:21:38 +00:00CommentedJan 24, 2024 at 9:21
Related questions
Related questions