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()`
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 4 Posters 536 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.
  • Please_Help_me_DP Offline
    Please_Help_me_DP Offline
    Please_Help_me_D
    wrote on last edited by CristianMaureira
    #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?

    jsulmJ 1 Reply Last reply
    0
    • Please_Help_me_DP Please_Help_me_D

      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?

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

      Please_Help_me_DP 1 Reply Last reply
      1
      • jsulmJ jsulm

        @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'))
        
        Please_Help_me_DP Offline
        Please_Help_me_DP Offline
        Please_Help_me_D
        wrote on last edited by CristianMaureira
        #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

        JonBJ 1 Reply Last reply
        0
        • Please_Help_me_DP Please_Help_me_D

          @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

          JonBJ Online
          JonBJ Online
          JonB
          wrote on 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?

          Please_Help_me_DP 1 Reply Last reply
          1
          • JonBJ JonB

            @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?

            Please_Help_me_DP Offline
            Please_Help_me_DP Offline
            Please_Help_me_D
            wrote on 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
            • CristianMaureiraC Offline
              CristianMaureiraC Offline
              CristianMaureira
              wrote on 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

              • Login

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