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. Read output Terminal with QProcess
Forum Updated to NodeBB v4.3 + New Features

Read output Terminal with QProcess

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 5 Posters 3.0k 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.
  • F Offline
    F Offline
    Franckynos
    wrote on 16 May 2017, 08:07 last edited by
    #1

    Hi,

    I try to read output of terminal with accent like this:

    //Read interface
        cmd = QString("netsh interface show interface");
        p.start(cmd);
        p.waitForFinished();
    
        QStringList list1;
        while(!p.atEnd())
        {
            list1.append(p.readLine());
        }
    
        qDebug() << list1;
    

    And my list1 =

    ("\r\n", "\uFFFDtat admin    \uFFFDtat          Type            Nom de l'interface\r\n", "-------------------------------------------------------------------------\r\n", "Activ\uFFFD         D\uFFFDconnect\uFFFD     D\uFFFDdi\uFFFD            Ethernet\r\n", "Activ\uFFFD         Connect\uFFFD       D\uFFFDdi\uFFFD            Connexion au r\uFFFDseau local* 13\r\n", "Activ\uFFFD         Connect\uFFFD       D\uFFFDdi\uFFFD            VirtualBox Host-Only Network\r\n", "Activ\uFFFD         Connect\uFFFD       D\uFFFDdi\uFFFD            VirtualBox Host-Only Network #2\r\n", "Activ\uFFFD         Connect\uFFFD       D\uFFFDdi\uFFFD            Wi-Fi\r\n", "Activ\uFFFD         D\uFFFDconnect\uFFFD     D\uFFFDdi\uFFFD            Ethernet 2\r\n", "\r\n")
    

    I don't know how reomve this \uFFFD normaly it's "é" char.

    Someone can help me to fix this ?

    Thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      m.sue
      wrote on 16 May 2017, 09:06 last edited by
      #2

      Hi,

      I would assume that the contents of list1 is correct, but that qDebug does not ise an encoding in the output.

      -Michael.

      1 Reply Last reply
      1
      • F Offline
        F Offline
        Franckynos
        wrote on 16 May 2017, 10:28 last edited by
        #3

        Exactlly !!!!

        i have tried some QString::fromUtf8 ...

        But never accent :(

        D 1 Reply Last reply 16 May 2017, 11:41
        0
        • F Franckynos
          16 May 2017, 10:28

          Exactlly !!!!

          i have tried some QString::fromUtf8 ...

          But never accent :(

          D Offline
          D Offline
          Devopia53
          wrote on 16 May 2017, 11:41 last edited by Devopia53
          #4

          @Franckynos

          Hi.

          Your console output contains the local charset.
          You can try QString::fromLocal8Bit() instead of QString::fromUtf8().
          Like this:

          list1.append(QString::fromLocal8Bit(p.readLine()));
          
          1 Reply Last reply
          0
          • F Offline
            F Offline
            Franckynos
            wrote on 16 May 2017, 11:56 last edited by
            #5

            I have already try this but \uFFFD is replace by \u201A

            Activ\u201A         D\u201Aconnect\u201A     D\u201Adi\u201A            Ethernet 2\r\n", "\r\n"
            
            J 1 Reply Last reply 16 May 2017, 12:00
            0
            • F Franckynos
              16 May 2017, 11:56

              I have already try this but \uFFFD is replace by \u201A

              Activ\u201A         D\u201Aconnect\u201A     D\u201Adi\u201A            Ethernet 2\r\n", "\r\n"
              
              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 16 May 2017, 12:00 last edited by
              #6

              @Franckynos What encoding is your terminal using?

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

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 16 May 2017, 22:18 last edited by
                #7

                Hi,

                You might also see the qDebug behaviour change described here.

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

                F 1 Reply Last reply 17 May 2017, 08:07
                0
                • S SGaist
                  16 May 2017, 22:18

                  Hi,

                  You might also see the qDebug behaviour change described here.

                  F Offline
                  F Offline
                  Franckynos
                  wrote on 17 May 2017, 08:07 last edited by
                  #8

                  @SGaist thx your have right, i have the 5.5.0.

                  1 Reply Last reply
                  0

                  1/8

                  16 May 2017, 08:07

                  • Login

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