Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
UTF-8 encoded files doesn’t open in Qt creator 2.2 64-bit under Ubuntu
winspear last edited by A Former User
I have a cross platform project that I created in Qt Creator for Windows and now I am not able to open the cpp files which are UTF-8 encoded under Linux Qt creator. It keeps saying
"Could not decode "filename" with UTF-8 encoding. Editing not possible. "
Good old VI editor is able to open it without problems. Even gEDit opens it fine.
Any help will be appreciated.
On the top right you should see an edit button/bar. When you click it you can select another encoding.
But i don't know why this happens sometimes.
I tried all the encodings from the drop down menu. None of them works. :(
bq. I tried all the encodings from the drop down menu
All of them? How many do you have? My list is huge.
What locale are you using on linux? Maybe you could use something else in ubuntu?
That message says that the file is not encoded in utf-8 but something else. Cleaning up special characters will most likely help as will converting in from the right encoding.
Where did you get creator from and which version is it?
This is all the locale I have on my system. Should I update my encodings by installing something ?
I downloaded 64-bit version of QT from here yesterday and I got the online installer. The install succeeded without errors.
Originally the cpp file was created using Visual studio 2005 under Windows.
Scylla last edited by
I have already seen this before. This happens somtimes if the file was created on windows (7). What do in this case is, I'm using a editor (pspad) and convert (to utf-8) and save this file again. After this I can open this file without problems in QtCreator on my linux
This files were created original within QtCreator (2.1) on Windows 7 (64Bit), so it's strange.
Thanks for the tip. Editing encoding in Qt Creator solved it for me but not forever. Sometimes i had to do it again. I will try it out when i get this error again., but it has been a while since i saw it.
My files were created using Qt Creator 2.1 on kubuntu 10.10 using the linux installer from the qt nokia website. When i open them on windows 7 64 bit with the qtsdk1.1 i got the same error as yours, but i could't reproduce it. That's why i didn't file a bug report.
Thanks Scylla. I finally ended up converting my files to UTF-8 using my Notepad++ application under Windows.
But I find it to be very unprofessional on part of QT Creator not being able to automatically recognize an encoded CPP file. For God's sake, it is supposed to be a C++ IDE.
Anyways, thanks for all your help.
Qt Creator by default uses the system encoding to save files. On windows the system encoding is dependent on your language and rarely UTF-8.
So if you work in cross-platform team decide on one encoding and make sure everybody uses that. If you want to enforce the encoding for all files, you can use a commit hook on your VCS server. That works well, even if some developers want to use other editors.
String constants in C++ files are dependent on the encoding of the file! Encodings are not necessarily interchangeable either: Just think of having to compare strings from some server somewhere to stored strings. You do not want those to fail because the encoding is a bit different. Combine that with the fact that guessing at an encoding is just that: Guessing and you do not want Creator to do that for you.
That explains it very well!
Thanks for the explanation Tobias.