interpreting non ascii codepoint
ProtoBuf 在Windows VS2019 C++平台上的使用
这两天想着了解一下protobuf,搜索了一篇博客照着弄了一下
https://blog.csdn.net/weixin_44780793/article/details/120572110
有个问题是,我对着弄后定义的.proto文件生成的时候报错了

一开始我以为是文件里有中文注释要弄成ANSI格式,发现还是不行



怎么改都不行,后边发现是用了中文状态下的;
改回去英文的;就通过了...
=============分割线===============
自己弄了个.proto,想着试试是否支持map和vector,发现map和c++的map写法一样,要用vector(数组)得用repeated +类型,这个测试文件如下
syntax = "proto3";
message ItemData {
int32 ItemID = 1;
map<int32,string> pos = 2;
int32 ItemNum = 3;
repeated int64 arr = 4;
}
测试代码:
ItemData item;
item.set_itemid(100);
item.set_itemnum(25); // 设置map
item.clear_pos();
auto pos = item.mutable_pos();
pos->insert({ 1,"first" }); // 设置数组
item.clear_arr();
item.add_arr(666);
item.add_arr(888); std::string str;
str = item.SerializeAsString();
std::cout << "str:" << str << std::endl;
std::cout << "反序列化:" << std::endl; ItemData item1;
item1.ParseFromString(str);
std::cout<<"Id:"<<item1.itemid();
std::cout << " num:" << item1.itemnum() << std::endl;; // 解析map
for (auto it : item1.pos())
{
std::cout << " key:" << it.first << " value:" << it.second << std::endl;
}
// 解析数组
for (auto it : item.arr())
{
std::cout << "v:" << it;
}
ps:发现map不是直接用的std的map,操作接口有些不一样
结果正常:

关于protobuf的简单探讨先到此为止了
interpreting non ascii codepoint的更多相关文章
- INFORMIX 时间函数大全
http://publib.boulder.ibm.com/infocenter/idshelp/v115/index.jsp?topic=/com.ibm.sqls.doc/ids_sqs_0187 ...
- Impala SQL 语言元素(翻译)[转载]
原 Impala SQL 语言元素(翻译) 本文来源于http://my.oschina.net/weiqingbin/blog/189413#OSC_h2_2 摘要 http://www.cloud ...
- Impala SQL 语言元素(翻译)
摘要: http://www.cloudera.com/content/cloudera-content/cloudera-docs/Impala/latest/Installing-and-Usin ...
- python2.7 处理unicode和ascii字符串混用问题
python2.7默认的编码方式为ascii码,如下可以查询: import sys sys.getdefaultencoding() 如果直接在unicode和ascii字符串之间做计算.比较.连接 ...
- CSS非ASCII字符最佳实践
问题场景 在写样式时经常需要用到非ASCII字符的属性值,如下: ? 1 2 3 4 5 6 7 8 9 10 11 .hot_list .sign_discount:before { cont ...
- SQL Server 中怎么查看一个字母的ascii编码或者Unicode编码
参考文章:微信公众号文章 在sql中怎么查看一个字符的ascii编码,so easy !! select ASCII('a') SELECT CHAR(97) charNum SELECT UNICO ...
- perl 如何匹配ASCII码以及ASCII码转换
匹配ASCII码: /[:ascii:]/ ASCII码转换为数字: ord() 数字转换为ASCII码: chr()
- 常用ASCII CHR碼對照
因為開發需求,把對照表留下來一下. Chr(0) Null Chr(29) 分组符 Chr(38) & Chr(48) 0 Chr(8) 退格 Chr(30) 記錄分離符號 Chr(39) ‘ ...
- ascii、unicode、utf、gb等编码详解
很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同的状态,以表示世界上的万物.他们看到8个开关状态是好的,于是他们把这称为"字节".再后来,他们又做了一些可以处理这 ...
- ASCII码而已
题目: \u5927\u5bb6\u597d\uff0c\u6211\u662f\u0040\u65e0\u6240\u4e0d\u80fd\u7684\u9b42\u5927\u4eba\uff01 ...
随机推荐
- Oracle RAC单节点启停
由于单节点操作系统需要重启维护,版本为12C 确认集群的db_unique_name,本初的db_unique_name为orcl SQL> show parameter name SQL> ...
- 复习第二点-2.基于注解的helloworld
web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="htt ...
- docker搭建图片压测QPS3000+服务器(ftp+nginx)
docker搭建图片压测QPS3000+服务器(ftp+nginx) 在针对图片算法服务进行压力测试时,需要高性能的图片服务器 自己编写的图片应用性能不一定能达到要求 可能因为图片应用自身达不到压测要 ...
- mysql报错This function has none of DETERMINISTIC. NO SOL or READS SOL DATA...
是因为 存储过程/存储函数在创建时 与 开启慢查询日志冲突了 解决冲突: 临时解决:开启log_bin_trust_function_creators show variables like '%lo ...
- Unity中UGUI图片跟随文本自适应方法
字体和图片层级如下 Text添加Content Size Fitter Image设置锚点
- 使用Promethues和Grafana监控Flink
之前使用Influxdb储存Metrics经常会出现数据写不进去的问题,当Influxdb重启之后又能写进去,遂将数据存储部分换成Promethues,因为Flink采用PutGateway的方式,需 ...
- springboot项目基于mybatis-plus创建逆向工程
pom 依赖 <!--web 依赖--><dependency> <groupId>org.springframework.boot</groupId> ...
- Linux 第五节 (shell脚本while循环,case,计划任务,用户及权限)
#!/bin/bash #this is a test script PRICE=$(expr $RANDOM % 1000) //将随机得出的数字取余 TIMES=0 while true do ...
- 一些sql查询的case
1.单列去重,输出去重后条目数量 select count(distinct(`id`)) from student; 2.根据分数段统计数据条目:利用case when selectcount(ca ...
- 3月1日至3月2日——数据结构与算法分析阅读笔记,线性表,AI。
(开头是一些废话啊,最近感觉学习状态不太好,上高数的时候左耳听进去右耳就出来了,有点跟不上,可能是没吃饭的原因,也可能是最近强度有点大了,下午上完课就给自己休息了一下,结果刷手机全是关于AI的内容,谢 ...