QTextCodec::setCodecForCStrings 在 Qt5 中消失了 [英] QTextCodec::setCodecForCStrings is GONE in Qt5

查看:82
本文介绍了QTextCodec::setCodecForCStrings 在 Qt5 中消失了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中所有显示的文本都是希腊语.我没有使用 tr(),直接使用希腊字符.对于我使用的正确编码:

All displayed text in my project is in Greek. I didn't use tr(), just Greek characters directly. And for the correct encoding I was using:

QTextCodec::setCodecForCStrings(QTextCodec::codecForName("ISO 8859-7"));//for Greek

Qt5把setCodecForCStrings拿走了,所有的字符都显示为"???????".有解决方法吗?

Qt5 took setCodecForCStrings away , and all the characters are displayed as "???????". Is there a workaround?

请注意这是一个大项目,我想避免对每个字符串使用代码程序.

Please note this is a big project, I want to avoid using code for every string in the program.

推荐答案

谢谢 Esailija

Thank you Esailija

所以用 UTF-8 编码保存我的所有文件解决了这个问题.

So saving all my files with UTF-8 encoding solved the problem.

如果您使用的是 Qt Creator,请将默认编码更改为 UTF-8:
首选项 -> 文本编辑器 -> 默认编码 ... 选择 UTF-8
然后对于现有文件,转到 Edit->Select Encoding 并将其更改为 UTF-8

If you are using Qt Creator, change the default encoding to UTF-8:
Preferences -> Text Editor -> Default Encoding ... choose UTF-8
Then for the existing files go to Edit->Select Encoding and change it to UTF-8

对于任何想要了解更多细节的人,请看这里 http://www.macieira.org/blog/2012/05/source-code-must-be-utf-8-and-qstring-wants-it/

also for anyone wanting more details look here http://www.macieira.org/blog/2012/05/source-code-must-be-utf-8-and-qstring-wants-it/

这篇关于QTextCodec::setCodecForCStrings 在 Qt5 中消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆