Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problems with Qt and strange caracters!
Forum Updated to NodeBB v4.3 + New Features

Problems with Qt and strange caracters!

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 4.3k Views 1 Watching
  • 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.
  • V Offline
    V Offline
    varexnet32
    wrote on last edited by
    #1

    hello guys !
    this code
    @ui->textView.setText("éèçàé");@
    would give me some ??? in the textview...
    the problem is not only related to simply the textview but it's also about writing to files,showing messageboxes
    how you think I can fix it
    I'm on windows now(I haven't yet tried it in linux) and I'm using the qt 4.7.4

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      The point here is how the source code file is stored (which encoding) and which encoding is used during conversion from char* to QString. You can search this forum for QString and conversion and should find some more details.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • V Offline
        V Offline
        varexnet32
        wrote on last edited by
        #3

        but how i can change the encoding in the editor!

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          How should we know, you did not tell us what editor you are using...

          P.S. This is exactly why I recommend not using non-ascii characters in source code at all, and using translations instead.

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

            [quote author="Andre" date="1317581829"]P.S. This is exactly why I recommend not using non-ascii characters in source code at all, and using translations instead.[/quote]

            Thats the best way, or type the octal codes instead.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • V Offline
              V Offline
              varexnet32
              wrote on last edited by
              #6

              I'm using Qt creator!
              actually about what you said I'm working with something different
              I first choose a file which contains those characters and then try to show them in the textview

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                So... how does your actual code look then?

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  varexnet32
                  wrote on last edited by
                  #8

                  wait until I reproduce something!

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    varexnet32
                    wrote on last edited by
                    #9

                    ok It was hard a little bit to remember the code I used In my old project (which I canceled and deleted)... but actually you can see it if you :
                    open the application that came shipped with Qt called textedit here is the directory in my windows : C:\QtSDK\Demos\4.7\textedit
                    and then create a text file containing this text : "
                    this is french : 'j'ai utilisé Qt mais à certain point il commence à m'énerver'
                    this is arabic : 'مهما كتبت هنا فهو لن يظهر بالعربية'
                    this is japanese : '私は本当にこの言葉を話すことはありません'
                    "
                    and try opening it :(

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on last edited by
                      #10

                      The encoding you save the text in, should match the encoding you try to load it from (or the other way around, of course). If you read the source code of the example, you can also see that it is dealing with encodings (lines 408-410). However, the code there mainly seems to try to deal with HTML encodings, not encodings of text files. You should investigate what the default codec is that is returned from the method in line 408 for a non-HTML file. If you store your file in that format, it will be loaded and displayed correctly.

                      Note that this is nothing like using a translation file though.

                      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