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. QString convert unicode
Forum Updated to NodeBB v4.3 + New Features

QString convert unicode

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 4 Posters 9.6k Views 2 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.
  • kshegunovK kshegunov

    Use QString::toUtf8() and/or QString::fromUtf8().

    J Offline
    J Offline
    Jeronimo
    wrote on last edited by kshegunov
    #4

    I edited your post by accident and its text was lost, I am sorry!

    ~kshegunov

    kshegunovK 1 Reply Last reply
    0
    • J Jeronimo

      I edited your post by accident and its text was lost, I am sorry!

      ~kshegunov

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #5

      @Jeronimo said in QString convert unicode:

      So i can convert in utf16 like

      You're doing it wrong.

      But i want to pass to unicode utf8

      As I said, use QString::toUtf8:

      wchar_t buffer[5]
      QString string = QString::fromWCharArray(buffer);
      char * utf8encoded = string.toUtf8();
      

      Read and abide by the Qt Code of Conduct

      J 1 Reply Last reply
      2
      • kshegunovK kshegunov

        @Jeronimo said in QString convert unicode:

        So i can convert in utf16 like

        You're doing it wrong.

        But i want to pass to unicode utf8

        As I said, use QString::toUtf8:

        wchar_t buffer[5]
        QString string = QString::fromWCharArray(buffer);
        char * utf8encoded = string.toUtf8();
        
        J Offline
        J Offline
        Jeronimo
        wrote on last edited by Jeronimo
        #6

        @kshegunov said in QString convert unicode:

        wchar_t buffer[5]

        say me the follow:
        'inicializando' : no se puede realizar la conversi¢n de 'QByteArray' a 'char *'
        No hay disponible ning£n operador de conversi¢n definido por el usuario que pueda realizar esta conversi¢n, o bien no se puede llamar al operador

        In other words when i do this

        wchar_t buffer[5];
        QString string = QString::fromWCharArray(buffer);
        char *utf8encoded = string.toUtf8();
        

        I can't do the conversion.

        kshegunovK 1 Reply Last reply
        0
        • J Jeronimo

          @kshegunov said in QString convert unicode:

          wchar_t buffer[5]

          say me the follow:
          'inicializando' : no se puede realizar la conversi¢n de 'QByteArray' a 'char *'
          No hay disponible ning£n operador de conversi¢n definido por el usuario que pueda realizar esta conversi¢n, o bien no se puede llamar al operador

          In other words when i do this

          wchar_t buffer[5];
          QString string = QString::fromWCharArray(buffer);
          char *utf8encoded = string.toUtf8();
          

          I can't do the conversion.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #7

          You really should check the docs on this.
          I've made a minor mistake, but it's easily correctable.

          QByteArray utf8data = string.toUtf8();
          const char * utf8encoded = utf8data.constData();
          

          Read and abide by the Qt Code of Conduct

          J 1 Reply Last reply
          2
          • kshegunovK kshegunov

            You really should check the docs on this.
            I've made a minor mistake, but it's easily correctable.

            QByteArray utf8data = string.toUtf8();
            const char * utf8encoded = utf8data.constData();
            
            J Offline
            J Offline
            Jeronimo
            wrote on last edited by
            #8

            @kshegunov said in QString convert unicode:

            QByteArray utf8data = string.toUtf8();
            const char * utf8encoded = utf8data.constData();

            one question normally i think must show unicode text like this :

            Normally i can do this
            QString::fromUtf16((ushort*)buffer)

            But i have one problem with this only show me in unicode when i am using some modificator like ctrl. It's for one keyboard in different languages.

            kshegunovK 1 Reply Last reply
            0
            • J Jeronimo

              @kshegunov said in QString convert unicode:

              QByteArray utf8data = string.toUtf8();
              const char * utf8encoded = utf8data.constData();

              one question normally i think must show unicode text like this :

              Normally i can do this
              QString::fromUtf16((ushort*)buffer)

              But i have one problem with this only show me in unicode when i am using some modificator like ctrl. It's for one keyboard in different languages.

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #9

              I don't understand the question. Unicode has little to do with control or with the keyboard, it's an encoding for text, not a device driver ...

              Read and abide by the Qt Code of Conduct

              J 1 Reply Last reply
              0
              • kshegunovK kshegunov

                I don't understand the question. Unicode has little to do with control or with the keyboard, it's an encoding for text, not a device driver ...

                J Offline
                J Offline
                Jeronimo
                wrote on last edited by
                #10

                @kshegunov i think is problem of my instance or i'm doing something wrong.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  Hi,

                  Then tell us what you are trying to do.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  J 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Hi,

                    Then tell us what you are trying to do.

                    J Offline
                    J Offline
                    Jeronimo
                    wrote on last edited by
                    #12

                    @SGaist Sorry i said instance¿? i wanted to say encoding*

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      That still doesn't explain what you are trying to do.

                      Why do you need all these conversion ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      J 1 Reply Last reply
                      1
                      • SGaistS SGaist

                        That still doesn't explain what you are trying to do.

                        Why do you need all these conversion ?

                        J Offline
                        J Offline
                        Jeronimo
                        wrote on last edited by
                        #14

                        @SGaist i'm trying to do keyboard in different languages and like i was trying to show key's in other languages like(german or others..) i couldn't because i can't get unicode text to translate it.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #15

                          Something like the QtVirtualKeyboard module ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          J 1 Reply Last reply
                          1
                          • SGaistS SGaist

                            Something like the QtVirtualKeyboard module ?

                            J Offline
                            J Offline
                            Jeronimo
                            wrote on last edited by
                            #16

                            @SGaist Nope it's for windows so i am using setwindowshookex

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #17

                              Why not make use of Window's virtual keyboard ?

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              J 2 Replies Last reply
                              1
                              • SGaistS SGaist

                                Why not make use of Window's virtual keyboard ?

                                J Offline
                                J Offline
                                Jeronimo
                                wrote on last edited by Jeronimo
                                #18
                                This post is deleted!
                                1 Reply Last reply
                                0
                                • SGaistS SGaist

                                  Why not make use of Window's virtual keyboard ?

                                  J Offline
                                  J Offline
                                  Jeronimo
                                  wrote on last edited by Jeronimo
                                  #19

                                  @SGaist Anyways i'm checking virtual keyboard thx

                                  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