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. Convert text in other encoding qt
Qt 6.11 is out! See what's new in the release blog

Convert text in other encoding qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 2.5k 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.
  • RIVOPICOR Offline
    RIVOPICOR Offline
    RIVOPICO
    wrote on last edited by RIVOPICO
    #1

    I am using QByteArray.
    I want to ask about which other conversions exist. I am normally using toLatin1 but i would try with others.

    datoss = "|@|" + ui->textocuenta->text().toLatin1() + "|@|"
    i am trying to use other conversion. Only that.

    raven-worxR 1 Reply Last reply
    0
    • RIVOPICOR RIVOPICO

      I am using QByteArray.
      I want to ask about which other conversions exist. I am normally using toLatin1 but i would try with others.

      datoss = "|@|" + ui->textocuenta->text().toLatin1() + "|@|"
      i am trying to use other conversion. Only that.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @RIVOPICO
      use QTextCodec::fromUnicode()

      QTextCodec * codec = QTextCodec::codecForName("CodecName")
      QByteArray data = codec->fromUnicode( utf8Str );
      

      For a possible list of codec values you can use QTextCodec::availableCodecs()

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • RIVOPICOR Offline
        RIVOPICOR Offline
        RIVOPICO
        wrote on last edited by RIVOPICO
        #3

        but in this example for example: how will be? thanks in advance. It is for having one example.
        datoss = "|@|" + ui->textocuenta->text().toLatin1() + "|@|"

        raven-worxR 1 Reply Last reply
        0
        • RIVOPICOR RIVOPICO

          but in this example for example: how will be? thanks in advance. It is for having one example.
          datoss = "|@|" + ui->textocuenta->text().toLatin1() + "|@|"

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @RIVOPICO

          QTextCodec * codec = QTextCodec::codecForName("CodecName")
          QByteArray encodedData = codec->fromUnicode( ui->textocuenta->text().toUtf8() );
          encodedData = QByteArray("|@|") + encodedData + QByteArray("|@|");
          

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1
          • RIVOPICOR Offline
            RIVOPICOR Offline
            RIVOPICO
            wrote on last edited by
            #5

            when i use this my tool crash i put the class and ; symbol that you forgot and crash. Show me the client stop working.

            jsulmJ 1 Reply Last reply
            0
            • RIVOPICOR RIVOPICO

              when i use this my tool crash i put the class and ; symbol that you forgot and crash. Show me the client stop working.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @RIVOPICO Did you check that codec is not null?

              QTextCodec * codec = QTextCodec::codecForName("CodecName");
              

              What did you pass as codec name?
              In such situations you should always debug first to see where and why your app crashes.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • RIVOPICOR Offline
                RIVOPICOR Offline
                RIVOPICO
                wrote on last edited by RIVOPICO
                #7

                sorry ok you are right now Works fine 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