grpc中c#和c++互相通信中文乱码问题解决方法

grpc中c#和c++互相通信中文乱码问题解决方法,第1张

原因是c#用的是utf-8编码而c++默认是"GBK"编码,转一下就好

 public override Task Ctrl_Feedback_Process(RpcRequest request, ServerCallContext context)
        {
            MainForm.Curent.AddScanData(request.Data.ToString(Encoding.GetEncoding("GBK")));
            return Task.FromResult(new RpcResponse() { Code = 0, Message = ByteString.CopyFrom("ok", Encoding.GetEncoding("GBK")) });
        }
 RpcResponse reply = client.Heart_Beat(new RpcRequest() { Head = user,Data = ByteString.CopyFrom("已登录", Encoding.GetEncoding("GBK")) });

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/662370.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-04-18
下一篇2022-04-18

发表评论

登录后才能评论

评论列表(0条)

    保存