当前位置:网站首页>qt中toLocal8Bit和toUtf8()有什么区别
qt中toLocal8Bit和toUtf8()有什么区别
2022-06-30 19:05:00 【hebao0】
将QString 字符串写入文件时,通常会借用QByteArray作为中间变量,有两种方法。
QString::toUtf8是输出UTF-8编码的字符集
QString::toLatin1是相当与ASCii码不包含中文的遇到中文默认转换为ascii码0x3f也就是字符’?‘
QString::Local8bit是本地操作系统设置的字符集编码,一般为GB2312.
查看本地操作系统设置的字符集编码,启动cmd ,输入chcp,
活动代码页为936,意思是"中国-简体中文(GB2312)"
QFile file("out.txt");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QString msg = "哈哈";
QByteArray byte= msg.toLocal8Bit();
file.write(byte);
file.close();

ANSI码(American National Standards Institute),在中国,这里理解成GB2312即可
边栏推荐
- 漫画 | Oracle 被新时代抛弃了吗?
- Abaqus 2022软件安装包和安装教程
- WordPress 博客使用火山引擎 veImageX 进行静态资源 CDN 加速(免费)
- Code shoe set - mt3111 · assignment
- Small notes - integer improvement (C language)
- 重复乃技艺之母
- Understanding of event queue, micro task and macro task and interview questions
- Task04: set operation - addition and subtraction of tables, join, etc. - learning notes of Tianchi Longzhu project SQL training camp
- Unity technical manual - preliminary performance optimization
- 广州炒股开户选择手机办理安全吗?
猜你喜欢
随机推荐
Go语言学习教程(十)
Growth summer challenge is coming, exclusive community welfare is coming ~ get CSDN customized T-shirt for free
PS2手柄-1「建议收藏」
A common mistake in enterprise model selection
A necessary tool for testing -- postman practical tutorial
VR云展厅如何给线下实体带来活力?有哪些功能?
二叉树终章
SQL continuous login problem
RP原型资源分享-购物类App
反射创建实例三种方式(2022.6.6-6.12)
配置服务器环境
Task01: getting to know database and SQL (Note 1)
【DesignMode】单例模式(singleton pattern)
sql连续登录问题
Is it safe to open an account for mobile phone stock trading!?
WordPress 博客使用火山引擎 veImageX 进行静态资源 CDN 加速(免费)
将 EMQX Cloud 数据通过公网桥接到 AWS IoT
实现各种效果和功能的按钮,读这篇文章就够了
Kubernetes为什么会赢,容器圈的风云变幻!
Connect to lab server
![[multithreading] use the thread pool to implement a simple thread pool](/img/24/ad3ced1d4aebde3f2233b04752bead.png)








