`
jackymin
  • 浏览: 72748 次
  • 性别: Icon_minigender_1
  • 来自: 哈尔滨
社区版块
存档分类
最新评论

protobuffer 中文乱码

阅读更多

protobuffer使用参看网络文档,此处说明如何解决属性中文乱码问题

1,构建时,用utf8统一转码
CMsg msg = CMsg.CreateBuilder()
.SetMsgcheck(head.ToByteString().ToStringUtf8())
.SetMsgstudent(body.ToByteString().ToStringUtf8())
.Build();

2,服务端读取信息时采用utf-8格式读取即可

CMsg msg = CMsg.ParseFrom(myRequestBuffer.RemoveEmptyByte(myRequestLength));

CMSgCheck head = CMSgCheck.ParseFrom(Encoding.UTF8.GetBytes(msg.Msgcheck));
CMsgStudent body = CMsgStudent.ParseFrom(Encoding.UTF8.GetBytes(msg.Msgstudent));

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics