Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator License Template file encoding problem
QtWS25 Last Chance

Qt Creator License Template file encoding problem

Scheduled Pinned Locked Moved Qt Creator and other tools
9 Posts 4 Posters 6.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    ludde
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Smar
        wrote on last edited by
        #3

        � 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
        0000001)

        1 Reply Last reply
        0
        • L Offline
          L Offline
          ludde
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            Can you look at the file with a hexeditor? It would be interesting, of which bytes it is actually made of.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • L Offline
              L Offline
              ludde
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tobias.hunger
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  ludde
                  wrote on last edited by
                  #8

                  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.

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tobias.hunger
                    wrote on last edited by
                    #9

                    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!

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved