当前位置:网站首页>QT将接收到的json数据(含中文)unicode转utf8
QT将接收到的json数据(含中文)unicode转utf8
2022-06-10 14:00:00 【南方有大雪】
最近在使用qt通过json数据格式传递数据,接收从设备传递到qt界面的数据显示,遇到了一个问题,具体为啥会出现的原因还位置。cpu通过json传递数据信息到qt端,因为数据信息含有中文,中文字符会默认转换未unicode格式传递,这样在qt端接收和解析json数据时,如果数据量过大,就会导致解析json数据失败,找不到对应的字符串(具体原因未知,判断应该是该原因造成的),数据量比较小暂时未出现该问题。
避免该问题的方法可以对接收到的数据都进行转码,转为utf8:
LocalSocket::instance()->recvMsg(msg);//接收到的数据
QTextCoder *code = QTextCodec::codevcForName("utf-8");
QByteArray msgUtf8 = code->fornUnicode(msg);//转码后的数据msgUtf8
边栏推荐
- Google Earth engine (GEE) - real time global 10 meter land use / land cover (LULC) data set based on S2 images
- buuctf [Discuz]wooyun-2010-080723
- Solve the problem that win10 virtual machine and host cannot paste and copy each other
- 格力手机叫板苹果手机?除了嘴硬之外,恐怕再无其他
- 2022年制冷与空调设备运行操作理论题库模拟考试平台操作
- [special introduction] round table forum -- the integration of AI and audio and video technology
- 自适应功能简略
- 【FAQ】運動健康服務REST API接口使用過程中常見問題和解决方法總結
- Win10 virtual machine download and installation process
- leetcode-57-插入区间
猜你喜欢

传奇登录器提示连接服务器失败是怎么回事?怎么解决?

【无标题】

Flutter Listview, Column, Row学习个人总结2

Solve the problem of cross sea high concurrent crash? so easy

二叉树和图2

Application analysis of key recording and playing of wt2003h4-16s voice chip

解决VMWareStation安装 tools 时 D:\setup.exe 找不到的问题

算力网络照进现实,浩鲸科技如何构建?

What does the multi cloud management platform CMP mean? Who can explain it clearly

Implementation of VGA protocol based on FPGA
随机推荐
buuctf [PHP]CVE-2019-11043
C#多线程学习笔记三
For the first time, the Pentagon admitted to funding 46 biological facilities in Ukraine. Russia once revealed that only three were safe
How to build Haojing technology when the computing power network is brought into reality?
Application analysis of key recording and playing of wt2003h4-16s voice chip
焱融看|混合云环境下,如何实现数据湖最优存储解决方案
多云管理平台cmp是什么意思?谁能清楚解释一下
【笔记】关于keil中的出现的编译映射内存不足的问题
大厂必备的40个方法论
基于FPGA的VGA协议实现
The shortcomings of the "big model" and the strengths of the "knowledge map"
【C语言】指针函数与函数指针、数组函数
[FAQ] résumé des problèmes courants et des solutions lors de l'utilisation de l'interface API rest du Service de santé sportive
C multithreading learning note 1
Pycharm安装详细教程
互联网公司研发效能团队为啥必须独立?何时独立?
buuctf [Discuz]wooyun-2010-080723
Microsoft Word 教程,如何在 Word 中更改页边距、创建新闻稿栏?
leetcode-57-插入区间
SnackBar usage details