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. Unicode character to readable format

Unicode character to readable format

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 6 Posters 5.0k 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.
  • E Offline
    E Offline
    eswar
    wrote on 11 Jan 2019, 13:12 last edited by
    #1

    Hi
    I have received Unicode character like "\u000B\u000E\u000E\u001E\u000E\u000E\u000E\u0013\u000E\u0014\u000E\n"

    I need to convert this in to readable format.

    A 1 Reply Last reply 11 Jan 2019, 13:37
    0
    • E eswar
      11 Jan 2019, 13:12

      Hi
      I have received Unicode character like "\u000B\u000E\u000E\u001E\u000E\u000E\u000E\u0013\u000E\u0014\u000E\n"

      I need to convert this in to readable format.

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 11 Jan 2019, 13:37 last edited by
      #2

      @eswar What do you mean with "readable". These characters are outside the letter/digit range and therefore cannot be displayed.

      Do you want to dump them as hex? Which type is the variable that stores that characters?

      Qt has to stay free or it will die.

      E 1 Reply Last reply 18 Jan 2019, 07:00
      1
      • O Offline
        O Offline
        ofmrew
        wrote on 11 Jan 2019, 14:29 last edited by
        #3

        Look at the UTF-8 encoding table. What you have are control chacters.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fcarney
          wrote on 11 Jan 2019, 15:39 last edited by
          #4

          Do you want to do something like "show codes" that used to be in Wordperfect back in the 90s?

          You might have to define your own unicode set to allow display of characters in a custom way. I have no idea what it takes to do such a thing.

          C++ is a perfectly valid school of magic.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fcarney
            wrote on 11 Jan 2019, 16:02 last edited by fcarney 1 Nov 2019, 16:11
            #5

            or... change the font that has control characters as visible characters.

            I actually want this for Qt. That way I can see the trailing spaces at the end of a line of code.

            Edit:
            Found it!
            In Qt Creator:
            Options->Text Editor->Display(tab)->Visualize Whitespace

            C++ is a perfectly valid school of magic.

            1 Reply Last reply
            0
            • A aha_1980
              11 Jan 2019, 13:37

              @eswar What do you mean with "readable". These characters are outside the letter/digit range and therefore cannot be displayed.

              Do you want to dump them as hex? Which type is the variable that stores that characters?

              E Offline
              E Offline
              eswar
              wrote on 18 Jan 2019, 07:00 last edited by
              #6

              @aha_1980

              Thanks for the reply. I need to convert this Unicode to string (Readble format).

              J 1 Reply Last reply 23 Jan 2019, 00:04
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 18 Jan 2019, 22:36 last edited by
                #7

                Hi,

                That's the catch: these are control characters, they don't have a visual representation. You will to replace them yourself with something if you want to make them "readable".

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

                E 1 Reply Last reply 22 Jan 2019, 07:05
                3
                • S SGaist
                  18 Jan 2019, 22:36

                  Hi,

                  That's the catch: these are control characters, they don't have a visual representation. You will to replace them yourself with something if you want to make them "readable".

                  E Offline
                  E Offline
                  eswar
                  wrote on 22 Jan 2019, 07:05 last edited by
                  #8

                  @SGaist

                  Thanks for the reply.

                  These are escape sequence Unicode data receiving from UART. I need to convert these unicode data to Qstring.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 22 Jan 2019, 07:43 last edited by
                    #9

                    That's what we are trying to make you understand: they already are in your QString but they have no visual representation. If you print the length of your string you'll see that it's not empty. You can process that string for whatever you need but you can't print anything readable.

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

                    1 Reply Last reply
                    2
                    • E eswar
                      18 Jan 2019, 07:00

                      @aha_1980

                      Thanks for the reply. I need to convert this Unicode to string (Readble format).

                      J Offline
                      J Offline
                      JKSH
                      Moderators
                      wrote on 23 Jan 2019, 00:04 last edited by
                      #10

                      @eswar said in Unicode character to readable format:

                      I need to convert this Unicode to string (Readble format).

                      Please tell us:

                      1. Why do you want to make the escape sequence "readable"?
                      2. Which Readable Format do you want to use? (there are many possible readable formats)
                      3. What do you want the final string to look like? Type it out for us.

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      1 Reply Last reply
                      1
                      • E Offline
                        E Offline
                        eswar
                        wrote on 23 Jan 2019, 05:38 last edited by eswar
                        #11

                        Hi @JKSH

                        For your information, the application read the weighing scale data through serial port. if i ran the application same application in windows machine, i will get the correct data .
                        Refer the attached image (0_1548221574250_windows.png image url)
                        if i ran the application in the linux machine, i will get the escape sequence data only.
                        Refer image (0_1548221760382_Linux.png link url) .
                        Both are same application screen shot with different machine. I dint know, Why it is behave in linux environment. If it is uni coded character in linux, i need to covert the character similar to the windows output.

                        A 1 Reply Last reply 23 Jan 2019, 06:17
                        0
                        • E eswar
                          23 Jan 2019, 05:38

                          Hi @JKSH

                          For your information, the application read the weighing scale data through serial port. if i ran the application same application in windows machine, i will get the correct data .
                          Refer the attached image (0_1548221574250_windows.png image url)
                          if i ran the application in the linux machine, i will get the escape sequence data only.
                          Refer image (0_1548221760382_Linux.png link url) .
                          Both are same application screen shot with different machine. I dint know, Why it is behave in linux environment. If it is uni coded character in linux, i need to covert the character similar to the windows output.

                          A Offline
                          A Offline
                          aha_1980
                          Lifetime Qt Champion
                          wrote on 23 Jan 2019, 06:17 last edited by
                          #12

                          @eswar The data you received is pure ASCII - it will work in Linux too if handled correctly.

                          Please show the code where you receive the data and how you store it in variables.

                          Qt has to stay free or it will die.

                          1 Reply Last reply
                          0
                          • E Offline
                            E Offline
                            eswar
                            wrote on 23 Jan 2019, 06:51 last edited by eswar
                            #13

                            Hi

                            Check the sample code for receiving data in the serial port.

                            connect(port,&QSerialPort::readyRead,this,&WeighingMachine::readData);

                            buffer is QByteArray datatype.

                            void WeighingMachine::readData()
                            {
                            QString Time = QTime::currentTime().toString("hh:mm:ss.zzz");

                            while(!(port->atEnd()))
                            {
                                buffer.append(port->readAll());
                            
                                int i =0;
                                QByteArray temp;
                                int len = buffer.length();
                            

                            #ifdef QT_DEBUG
                            qDebug()<<"Buffer: "<< QString::fromUtf8(buffer);;
                            #endif

                                while(i<len)
                                {
                            
                                    if ((buffer.at(i)== '\r') && (temp.length() > 0))
                                    {
                                        QString str(temp);
                                        QString Find = "\n";
                                        QString replace = "";
                                        str.replace(str.indexOf(Find),Find.size(),replace);
                                        weighingMachineData = Time +"," +str;
                            

                            #ifdef QT_DEBUG
                            // qDebug()<<"Weighing Data: "<<weighingMachineData;
                            #endif

                                        temp.clear();
                                    }
                                    else
                                    {
                                        temp.append(buffer.at(i));
                                    }
                            
                                    i++;
                                }
                                buffer.clear();
                                buffer.append(temp);
                                temp.clear();
                            }
                            

                            }

                            For your information, I also receive the same data in cutecom terminal also.

                            A 1 Reply Last reply 23 Jan 2019, 07:13
                            0
                            • E eswar
                              23 Jan 2019, 06:51

                              Hi

                              Check the sample code for receiving data in the serial port.

                              connect(port,&QSerialPort::readyRead,this,&WeighingMachine::readData);

                              buffer is QByteArray datatype.

                              void WeighingMachine::readData()
                              {
                              QString Time = QTime::currentTime().toString("hh:mm:ss.zzz");

                              while(!(port->atEnd()))
                              {
                                  buffer.append(port->readAll());
                              
                                  int i =0;
                                  QByteArray temp;
                                  int len = buffer.length();
                              

                              #ifdef QT_DEBUG
                              qDebug()<<"Buffer: "<< QString::fromUtf8(buffer);;
                              #endif

                                  while(i<len)
                                  {
                              
                                      if ((buffer.at(i)== '\r') && (temp.length() > 0))
                                      {
                                          QString str(temp);
                                          QString Find = "\n";
                                          QString replace = "";
                                          str.replace(str.indexOf(Find),Find.size(),replace);
                                          weighingMachineData = Time +"," +str;
                              

                              #ifdef QT_DEBUG
                              // qDebug()<<"Weighing Data: "<<weighingMachineData;
                              #endif

                                          temp.clear();
                                      }
                                      else
                                      {
                                          temp.append(buffer.at(i));
                                      }
                              
                                      i++;
                                  }
                                  buffer.clear();
                                  buffer.append(temp);
                                  temp.clear();
                              }
                              

                              }

                              For your information, I also receive the same data in cutecom terminal also.

                              A Offline
                              A Offline
                              aha_1980
                              Lifetime Qt Champion
                              wrote on 23 Jan 2019, 07:13 last edited by
                              #14

                              @eswar said in Unicode character to readable format:

                              #ifdef QT_DEBUG
                              qDebug()<<"Buffer: "<< QString::fromUtf8(buffer);;
                              #endif

                              Please change that to: qDebug() << "Buffer:" << buffer << "hex:" << buffer.toHex(); and post the output here.

                              Thanks.

                              Qt has to stay free or it will die.

                              1 Reply Last reply
                              1
                              • E Offline
                                E Offline
                                eswar
                                wrote on 23 Jan 2019, 09:08 last edited by
                                #15

                                @aha_1980

                                Please refer the following image
                                0_1548234468992_linux1.png

                                A 1 Reply Last reply 23 Jan 2019, 09:47
                                0
                                • E eswar
                                  23 Jan 2019, 09:08

                                  @aha_1980

                                  Please refer the following image
                                  0_1548234468992_linux1.png

                                  A Offline
                                  A Offline
                                  aha_1980
                                  Lifetime Qt Champion
                                  wrote on 23 Jan 2019, 09:47 last edited by
                                  #16

                                  @eswar That is really strange - all these characters are outside the visible ASCII range.

                                  • Do you have a documentation for the command set of the device you are talking with?
                                  • Can you repeat the last qDebug() tests in Windows?
                                  • Are you sure the serial parameters (baudrate, start, stop bits, parity) are correct in Linux?

                                  Qt has to stay free or it will die.

                                  1 Reply Last reply
                                  0
                                  • E Offline
                                    E Offline
                                    eswar
                                    wrote on 23 Jan 2019, 10:39 last edited by
                                    #17

                                    Hi @aha_1980

                                    Please refer below images for windows output
                                    0_1548239849949_Windows.JPG

                                    serial parameters are same for both linux and windows.
                                    In device documentation, transmission data format is mentioned as 8 bit ASCII format.

                                    A 1 Reply Last reply 23 Jan 2019, 10:41
                                    0
                                    • E eswar
                                      23 Jan 2019, 10:39

                                      Hi @aha_1980

                                      Please refer below images for windows output
                                      0_1548239849949_Windows.JPG

                                      serial parameters are same for both linux and windows.
                                      In device documentation, transmission data format is mentioned as 8 bit ASCII format.

                                      A Offline
                                      A Offline
                                      aha_1980
                                      Lifetime Qt Champion
                                      wrote on 23 Jan 2019, 10:41 last edited by
                                      #18

                                      @eswar Something is terribly wrong in Linux - I'd blame the serial parameters.

                                      You need to find the culprit before you can continue.

                                      Best start with a terminal program in Linux and see if you can receive the data correctly there.

                                      Qt has to stay free or it will die.

                                      1 Reply Last reply
                                      0
                                      • E Offline
                                        E Offline
                                        eswar
                                        wrote on 23 Jan 2019, 10:46 last edited by
                                        #19

                                        @aha_1980

                                        Thanks for the support.

                                        Cutecom was also receive the same thing. So only i am not able to find the problem. Find below,
                                        0_1548240335682_cutecom.JPG

                                        A 1 Reply Last reply 23 Jan 2019, 11:19
                                        0
                                        • E eswar
                                          23 Jan 2019, 10:46

                                          @aha_1980

                                          Thanks for the support.

                                          Cutecom was also receive the same thing. So only i am not able to find the problem. Find below,
                                          0_1548240335682_cutecom.JPG

                                          A Offline
                                          A Offline
                                          aha_1980
                                          Lifetime Qt Champion
                                          wrote on 23 Jan 2019, 11:19 last edited by
                                          #20

                                          @eswar

                                          Ok, so some more questions:

                                          • Is this Linux system a regular PC? Is it the same running Windows?
                                          • How do you connect the device to the PC? True RS-232, or USB (like FTDI?)
                                          • Is the external device properly powered?

                                          Qt has to stay free or it will die.

                                          E 1 Reply Last reply 24 Jan 2019, 06:39
                                          1

                                          9/24

                                          22 Jan 2019, 07:43

                                          15 unread
                                          • Login

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