【问题标题】:Text encoding of Protocol Buffers string fieldsProtocol Buffers 字符串字段的文本编码
【发布时间】:2018-09-19 13:12:47
【问题描述】:

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

【问题讨论】:

    标签: c++ character-encoding protocol-buffers


    【解决方案1】:

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

    Language Guide

    字符串必须始终包含 UTF-8 编码或 7 位 ASCII 文本。

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

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

    【讨论】:

      猜你喜欢
      • 2020-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-09
      • 2015-08-25
      • 1970-01-01
      • 2015-06-10
      相关资源
      最近更新 更多