Error Message - Could Not Decode [Solved]
-
Using QTCreator..4.7.2
Basically copied source from a QT dev environment on Win7 to a Mac.
What does the following mean? The error displays above the QT Creator source code window when trying to open a specific .cpp file.
@
Could Not Decode "filename.cpp" with "System"-encoding. Editing not possible.@All other source modules can be edited. Just not this one. The really curious thing is that the "filename.ui" file can be edited...just the source gives the error.
What does the error mean and how do I correct?
-
perhaps you encoded it in some special codepage from windows? does it contain some special chars, which are not ASCII 7-bit?
-
perhaps you encoded it in some special codepage from windows
Not that I'm aware of. All the source files were created with QT Creator. I copied the entire project directory from the Win dev system, to a memory stick, and then to the Mac.
Is it possible that one of the QT generated files( .o ui_ or moc ) is causing the issue?
I did do a "Clean All" and a "Clean Project". I would have thought a QT generated files would have been deleted by doing so.
Kinda stumped.
-
.o files are not opened by Creator. The autogenerated ui_xx and moc_xxx files are quite platform independent.
It's quite likely that filename.cpp is saved with a windows specific encoding, but not in a platform independent encoding like utf-8.
To check, open the preferences in Qt Creator, go to "Text Editor", then to tab "behavior" and look for the default encoding.
If the error message appears again, you should be presented with the option to choose a different encoding to load the file with. Choose the one, that's used on windows (most probably windows-1252/CP1252).
-
Volker,
Thanks. Checked the “Text Editor>Behavior” tab, but on the Creator version I'm using on Win7, there's actually an "Environment" top level option that has the "Default File Encoding" selection combo.
I currently have it set to "System"..assuming that would be a generic option that would work on both Windows and Mac. Which it did for all files in the project except 1. That one file throws the error in the origianl post. Odd.
Unfortunately, on the Mac, when the error is displayed, no option to change the encoding is offered..just the error message.
Is there another encoding setting that would work on both Windows and Macs? You mentioned UTF-8..
There is also a "ui_filename.h" file that appears to be a generated .h supplied by Creator. Is it possible that the encoding error is in the .h file that is included by the .ccp throwing the error?
-
Can you provide the file somewhere, download would be best, as pasting it here in the forums will destroy the original encoding.
-
Volker,
The suggestion..
bq.
If the error message appears again, you should be presented with the option to choose a different encoding to load the file with. Choose the one, that’s used on windows (most probably windows-1252/CP1252)...worked.
I didn't see the "option button" at the far right of the error message. The button was/is the same color as the message bar and it blended in.
I opend the dialog by clicking the button and after selecting a couple format options that did not have a effect, the one for "mac..." fixed the file having the problem.
Still not sure why only 1 .cpp file in the project had a problem, but at this point problem is solved.
Thanks.
-
Be sure and edit the post title to add [Solved].