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

Encoding

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 1.5k 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.
  • N Offline
    N Offline
    narayanan.krish
    wrote on last edited by
    #1

    Hello all,

    I'm facing a issue related to encoding. I'm getting a response from server which contains Foreign charatcters (Chinese). I'm using QNetworkReply and reading the reply from the server. I'm on Ubuntu 14.04 machine and Qt 5.8. Instead of Chinese characters, it displays ??? symbols. Any help is greatly appreciated.

    This is the snippet of the code:

    @
    // Reply data reading and JSON conversion
    QByteArray data = reply->readAll();
    QJsonParseError parsingResult;
    QJsonDocument jsonDocument = QJsonDocument::fromJson(data, &parsingResult);

    QJsonObject jsonObject = jsonDocument.object();
    qDebug() << "Seond_language" << jsonObject["second_language"].toVariant().; //op -> ???

    @

    --nara

    Pablo J. RoginaP jsulmJ 2 Replies Last reply
    0
    • N narayanan.krish

      Hello all,

      I'm facing a issue related to encoding. I'm getting a response from server which contains Foreign charatcters (Chinese). I'm using QNetworkReply and reading the reply from the server. I'm on Ubuntu 14.04 machine and Qt 5.8. Instead of Chinese characters, it displays ??? symbols. Any help is greatly appreciated.

      This is the snippet of the code:

      @
      // Reply data reading and JSON conversion
      QByteArray data = reply->readAll();
      QJsonParseError parsingResult;
      QJsonDocument jsonDocument = QJsonDocument::fromJson(data, &parsingResult);

      QJsonObject jsonObject = jsonDocument.object();
      qDebug() << "Seond_language" << jsonObject["second_language"].toVariant().; //op -> ???

      @

      --nara

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @narayanan.krish I'd check if a proper font with support for the characters you expect is available...

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • N narayanan.krish

        Hello all,

        I'm facing a issue related to encoding. I'm getting a response from server which contains Foreign charatcters (Chinese). I'm using QNetworkReply and reading the reply from the server. I'm on Ubuntu 14.04 machine and Qt 5.8. Instead of Chinese characters, it displays ??? symbols. Any help is greatly appreciated.

        This is the snippet of the code:

        @
        // Reply data reading and JSON conversion
        QByteArray data = reply->readAll();
        QJsonParseError parsingResult;
        QJsonDocument jsonDocument = QJsonDocument::fromJson(data, &parsingResult);

        QJsonObject jsonObject = jsonDocument.object();
        qDebug() << "Seond_language" << jsonObject["second_language"].toVariant().; //op -> ???

        @

        --nara

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

        @narayanan.krish You should not verify this using qDebug. qDebug prints to console and whether the console can show such characters or not depends on its configuration. Try to put this text into QLabel or QTextEdit.

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

        N 2 Replies Last reply
        2
        • jsulmJ jsulm

          @narayanan.krish You should not verify this using qDebug. qDebug prints to console and whether the console can show such characters or not depends on its configuration. Try to put this text into QLabel or QTextEdit.

          N Offline
          N Offline
          narayanan.krish
          wrote on last edited by
          #4

          @jsulm ,

          Thanks for the reply. I'm already exporting that variable to QML. In QML I use a Text component to display the string. Also, to confirm if this could be an encoding issue, I created a sample test console application with similar code snippet as above (Instead of readll(), I hard code the chinese characters in QByteArray). This worked and I'm able to see the Chinese characters on terminal using qDebug(). Also, can you please let me know how else I can test this ? Could it be w.r.t system configuration. If yes, any chances to check in Ubuntu 14.04 ?

          --nara

          jsulmJ 1 Reply Last reply
          0
          • N narayanan.krish

            @jsulm ,

            Thanks for the reply. I'm already exporting that variable to QML. In QML I use a Text component to display the string. Also, to confirm if this could be an encoding issue, I created a sample test console application with similar code snippet as above (Instead of readll(), I hard code the chinese characters in QByteArray). This worked and I'm able to see the Chinese characters on terminal using qDebug(). Also, can you please let me know how else I can test this ? Could it be w.r.t system configuration. If yes, any chances to check in Ubuntu 14.04 ?

            --nara

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

            @narayanan.krish What encoding is used to transfer this JSON?

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

            N 1 Reply Last reply
            0
            • jsulmJ jsulm

              @narayanan.krish You should not verify this using qDebug. qDebug prints to console and whether the console can show such characters or not depends on its configuration. Try to put this text into QLabel or QTextEdit.

              N Offline
              N Offline
              narayanan.krish
              wrote on last edited by
              #6

              @jsulm

              Thanks for the reply. I already tested it with the list of fonts installed in the PC.In ubuntu I checked using fc-list command.

              --nara

              jsulmJ 1 Reply Last reply
              0
              • jsulmJ jsulm

                @narayanan.krish What encoding is used to transfer this JSON?

                N Offline
                N Offline
                narayanan.krish
                wrote on last edited by
                #7

                @jsulm

                Actually we've not specified any format for the charset in the header. Could this be an issue ?

                --nara

                1 Reply Last reply
                0
                • N narayanan.krish

                  @jsulm

                  Thanks for the reply. I already tested it with the list of fonts installed in the PC.In ubuntu I checked using fc-list command.

                  --nara

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

                  @narayanan.krish I don't mean fonts. Is it UTF-8, UTF-16, ...?

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

                  N 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @narayanan.krish I don't mean fonts. Is it UTF-8, UTF-16, ...?

                    N Offline
                    N Offline
                    narayanan.krish
                    wrote on last edited by
                    #9

                    @jsulm

                    No, I don't think we've specified the encoding. Can you please let me know if you are referring to request.setRawHeader(...) while sending a request ?

                    --nara

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      narayanan.krish
                      wrote on last edited by
                      #10

                      Solved. The issue was due to missing fonts.

                      --nara

                      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