gpt4 book ai didi

c++ - Protocol Buffers 字符串字段的文本编码

转载 作者:太空狗 更新时间:2023-10-29 21:10:52 26 4
gpt4 key购买 nike

如果 C++ 程序接收到带有 Protocol Buffers string field 的 Protocol Buffers 消息,由 std::string 表示,该字段中文本的编码是什么?是 UTF-8 吗?

最佳答案

Protobuf 字符串始终是有效的 UTF-8 字符串。

参见 Language Guide :

A string must always contain UTF-8 encoded or 7-bit ASCII text.

(并且 ASCII 始终也是有效的 UTF-8。)

并非所有 protobuf 实现都强制执行此操作,但如果我没记错的话,至少 Python 库拒绝解码非 unicode 字符串。

关于c++ - Protocol Buffers 字符串字段的文本编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52384082/

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