Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQt Unable to correctly print Unicode from `QProcess.readAllStandardOutput()`
Forum Updated to NodeBB v4.3 + New Features

PyQt Unable to correctly print Unicode from `QProcess.readAllStandardOutput()`

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 4 Posters 602 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.
  • P Offline
    P Offline
    Please_Help_me_D
    wrote on 21 Jul 2022, 20:10 last edited by CristianMaureira 8 Feb 2022, 11:27
    #1

    Hi,

    I don't fully understand how Unicode transformation is done and I've seen some topics (they helped me a bit) like this one
    But still I'm going to clarify one thing:

    I make a QProcess that should produce these symbols ℯαΔ.
    Being more specific I make a call to julia programming language like this:

        self.qprocess.setProgram('julia.exe')
        self.qprocess.setArguments(['-E', '@info("ℯαΔ");'])
        self.qprocess.start()
    
      def onProcessReadyReadStandardOutput(self):
        print("QProcess output:\t", str(self.qprocess.readAllStandardOutput().data(), 'utf-8'))
    

    The printed output is [ Info: ea?
    The same output I get when running the same code from Windows powershell .\julia.exe -E '@info(\"ℯαΔ\")'

    I believe the output that I get from python is affected by the fact that Windows command line doesn't support Unicode. Is that right?
    Is there a way to avoid that and produce correct output from python?

    J 1 Reply Last reply 22 Jul 2022, 05:34
    0
    • P Please_Help_me_D
      21 Jul 2022, 20:10

      Hi,

      I don't fully understand how Unicode transformation is done and I've seen some topics (they helped me a bit) like this one
      But still I'm going to clarify one thing:

      I make a QProcess that should produce these symbols ℯαΔ.
      Being more specific I make a call to julia programming language like this:

          self.qprocess.setProgram('julia.exe')
          self.qprocess.setArguments(['-E', '@info("ℯαΔ");'])
          self.qprocess.start()
      
        def onProcessReadyReadStandardOutput(self):
          print("QProcess output:\t", str(self.qprocess.readAllStandardOutput().data(), 'utf-8'))
      

      The printed output is [ Info: ea?
      The same output I get when running the same code from Windows powershell .\julia.exe -E '@info(\"ℯαΔ\")'

      I believe the output that I get from python is affected by the fact that Windows command line doesn't support Unicode. Is that right?
      Is there a way to avoid that and produce correct output from python?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 22 Jul 2022, 05:34 last edited by
      #2

      @Please_Help_me_D said in PythonQt (PyQt) Unable to correctly print Unicode from `QProcess.readAllStandardOutput()`:

      def onProcessReadyReadStandardOutput(self):
      print("QProcess output:\t", str(self.qprocess.readAllStandardOutput().data(), 'utf-8'))

      Try

      def onProcessReadyReadStandardOutput(self):
          print("QProcess output:\t", str(QString(self.qprocess.readAllStandardOutput()), 'utf-8'))
      

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

      P 1 Reply Last reply 28 Jul 2022, 15:35
      1
      • J jsulm
        22 Jul 2022, 05:34

        @Please_Help_me_D said in PythonQt (PyQt) Unable to correctly print Unicode from `QProcess.readAllStandardOutput()`:

        def onProcessReadyReadStandardOutput(self):
        print("QProcess output:\t", str(self.qprocess.readAllStandardOutput().data(), 'utf-8'))

        Try

        def onProcessReadyReadStandardOutput(self):
            print("QProcess output:\t", str(QString(self.qprocess.readAllStandardOutput()), 'utf-8'))
        
        P Offline
        P Offline
        Please_Help_me_D
        wrote on 28 Jul 2022, 15:35 last edited by CristianMaureira 8 Feb 2022, 11:28
        #3

        @jsulm I'm sorry for the delay, haven't seen notification.

        It seems that PyQt doesn't have QString class.
        Is there a way to try it probably with QByteArray? Or something elese without QString

        J 1 Reply Last reply 28 Jul 2022, 18:55
        0
        • P Please_Help_me_D
          28 Jul 2022, 15:35

          @jsulm I'm sorry for the delay, haven't seen notification.

          It seems that PyQt doesn't have QString class.
          Is there a way to try it probably with QByteArray? Or something elese without QString

          J Offline
          J Offline
          JonB
          wrote on 28 Jul 2022, 18:55 last edited by
          #4

          @Please_Help_me_D
          Not my area, but there seem to be plenty of questions to look through from Googling print Unicode from QProcess.readAllStandardOutput()? E.g. maybe https://stackoverflow.com/questions/41761132/pyqt-qprocess-readallstandardoutput-encoding helps?

          P 1 Reply Last reply 28 Jul 2022, 19:18
          1
          • J JonB
            28 Jul 2022, 18:55

            @Please_Help_me_D
            Not my area, but there seem to be plenty of questions to look through from Googling print Unicode from QProcess.readAllStandardOutput()? E.g. maybe https://stackoverflow.com/questions/41761132/pyqt-qprocess-readallstandardoutput-encoding helps?

            P Offline
            P Offline
            Please_Help_me_D
            wrote on 28 Jul 2022, 19:18 last edited by
            #5

            @JonB thank you for reply,

            I tried googling that and tried to apply their solutions, but there was no way I could display alpha, beta, phi etc correctly.

            Me neither I don't understand all that encoding staff. I only have some basic "knowledge" on that

            1 Reply Last reply
            0
            • C Offline
              C Offline
              CristianMaureira
              wrote on 2 Aug 2022, 11:29 last edited by
              #6

              (Just modified the title, because PythonQt is another project and for future readers, I hope they don't get it wrong when talking about PyQt)

              1 Reply Last reply
              1

              1/6

              21 Jul 2022, 20:10

              • Login

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