Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt Creator License Template file encoding problem
Trying to add a copyright character, "©", to my License Template file used by Qt Creator.
But when I use this License Template file in Qt Creator the new files instead contain "ï¿½".
This is on Windows, using Qt Creator 2.0.1, with the file encoding set to "system".
Is there something I can do in Qt Creator or with my License Template file to make the
copyright character appear as a copyright character in Qt Creator?
Using copy and paste I have no problems inserting copyright characters, so it's easy to
fix this manually, but it sure would be nice if it just worked automatically...
What is your system encoding? Does it actually contain the © sign?
How did you set up encodings in Creator?
Try setting teh default encoding in creator to UTF-8 and make sure your template is UTF-8 encoded.
Smar last edited by
ï¿½ IIRC is garbage generated by UTF-8 content that has been rendered as latin1 and then rendered as UTF-8... Or something similar.
So there is some strange double convertion going on, Windows’ default encoding profile is CP-1252, so if the file was read as UTF-8, the output should be something similar to �
(hexdump: 0000000 00a9
Not 100% sure how to check what the system encoding is... I would assume it is Windows-1252 or ISO-8859-1 (Latin1). I did not set anything up in Qt Creator at all. The option "Default file encoding" is "System" by default.
In both Latin1 and Windows-1252, the copyright character is character number 169 (A9 in hex).
That is the character that is in the file.
I can look at my License Template file in any text editor / browser, and it is shown as a copyright character. This is the case also in Qt Creator, if I open the file as a text file just to look at it / edit it.
I guess I could try using UTF-8, but I don't really want to use that for my source code...
goetz last edited by
Can you look at the file with a hexeditor? It would be interesting, of which bytes it is actually made of.
Sorry for being a bit unclear, but what I meant when I said "That is the character that is in the file" was that in the file, the copyright character is made up of one byte, with the value 169 (or A9 in hex).
Seems like Qt Creator does some form of conversion to and from UTF-8 (even though it shouldn't really have to, since all files are in Windows-1252) and does it wrong.
ludde: Qt uses unicode internally for all its strings. So of course Creator does the same.
The contents of the license template is assumed to be UTF-8 encoded. The file is a template after all! You want it to work after copying it to another machine: So depending on the system encoding is not a good idea.
OK, I tried with UTF-8-encoded License File, and UTF-8 as default file encoding. And then it works.
(And that's the only combination that works.)
But, I don't want to use UTF-8. I agree that using the system encoding might be a bad idea, but you should be allowed to choose any encoding you want - otherwise, what is the point of having the "default file encoding" option? We use ISO-8859-1 for all our source code, and I'm sure a lot of other projects do that as well.
What I would expect, is Qt Creator to expect the License Template file to be in the "default file encoding". I will file a bug report about this.
Why should we want to worry about the encoding of the template when we can just use unicode which is a superset of all the others?
That the file generated from the template does not get converted properly when saving it is a bug indeed.
Thank you for considering to "file a bug report":http://bugreports.qt.nokia.com/ about this!