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

Read output Terminal with QProcess

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 5 Posters 3.2k 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.
  • FranckynosF Offline
    FranckynosF Offline
    Franckynos
    wrote on 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.sueM Offline
      m.sueM Offline
      m.sue
      wrote on 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
      • FranckynosF Offline
        FranckynosF Offline
        Franckynos
        wrote on last edited by
        #3

        Exactlly !!!!

        i have tried some QString::fromUtf8 ...

        But never accent :(

        D 1 Reply Last reply
        0
        • FranckynosF Franckynos

          Exactlly !!!!

          i have tried some QString::fromUtf8 ...

          But never accent :(

          D Offline
          D Offline
          Devopia53
          wrote on 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
          • FranckynosF Offline
            FranckynosF Offline
            Franckynos
            wrote on 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"
            
            jsulmJ 1 Reply Last reply
            0
            • FranckynosF Franckynos

              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"
              
              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on 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
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 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

                FranckynosF 1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi,

                  You might also see the qDebug behaviour change described here.

                  FranckynosF Offline
                  FranckynosF Offline
                  Franckynos
                  wrote on last edited by
                  #8

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

                  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