Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QTextCodec::setCodecForCStrings is GONE in Qt5

Tags:

unicode

qt5

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 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.

like image 350
user1918221 Avatar asked Dec 20 '12 09:12

user1918221


1 Answers

Thank you Esailija

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

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

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/

like image 146
user1918221 Avatar answered Oct 09 '22 23:10

user1918221