ByteSize(); char* buf = (char *)malloc(lenSend); odl->SerializeToArray(-6ren">
gpt4 book ai didi

protocol-buffers - Google Protocol Buffer 错误 : "Encountered string containing invalid UTF-8 data while serializing protocol buffer"

转载 作者:行者123 更新时间:2023-12-01 10:01:49 32 4
gpt4 key购买 nike

我正在使用以下代码

int lenSend = odl->ByteSize();
char* buf = (char *)malloc(lenSend);
odl->SerializeToArray(buf, lenSend);

我收到此错误,但我不明白为什么会收到此错误(是的,我收到了 3 次):

libprotobuf ERROR google/protobuf/wire_format.cc:1059] Encountered string containing invalid UTF-8 data while serializing protocol buffer. Strings must contain only UTF-8; use the 'bytes' type for raw bytes.
libprotobuf ERROR google/protobuf/wire_format.cc:1059] Encountered string containing invalid UTF-8 data while serializing protocol buffer. Strings must contain only UTF-8; use the 'bytes' type for raw bytes.
libprotobuf ERROR google/protobuf/wire_format.cc:1059] Encountered string containing invalid UTF-8 data while serializing protocol buffer. Strings must contain only UTF-8; use the 'bytes' type for raw bytes.



谢谢。

最佳答案

您可以按照消息中的建议去除警告!

您必须在 odl 的定义中有一个或多个字段(在您的 .proto 文件中)定义为 string但您将非 UTF-8 字符放入其中。 The docs state that you shouldn't do this .如果您将这些更改为 bytes ,警告应该消失。

关于protocol-buffers - Google Protocol Buffer 错误 : "Encountered string containing invalid UTF-8 data while serializing protocol buffer",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15139449/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com