[PyQt] UnicodeDecodeError with output from Windows OS command
jnbarchan at gmail.com
Thu Nov 30 15:42:15 GMT 2017
On 30 November 2017 at 14:42, Valentin Valls <valentin.valls at esrf.fr> wrote:
> On 11/30/2017 12:24 PM, Florian Bruhin wrote:
> > On Thu, Nov 30, 2017 at 12:12:17PM +0100, Valentin Valls wrote:
> >> stream = qt.QDataStream(byte_array, qt.QIODevice.ReadOnly)
> >> my_string = stream.readQString()
> > This really isn't what a QDataStream is for... and I don't see how it
> > work. For me, it doesn't:
> > >>> from PyQt5 import QtCore
> > >>> ba = QtCore.QByteArray(b'hello')
> > >>> s = QtCore.QDataStream(ba, QtCore.QIODevice.ReadOnly)
> > >>> s.readQString()
> > ''
> If you don't use QDataStream to write your data i don't see why you try
> to use it to read.
> PyQt mailing list PyQt at riverbankcomputing.com
Valentin, unfortunately your solution did not work for me either. All the
strings simply come back empty.
Maybe you are talking at cross purposes from the question I am asking, and
Florian who is trying to help me.
I am not in control at all of the writing side --- that is the output of
some arbitrary external application.
Qt lets me *read *its output as a QByteArray. and I need to convert that to
But I don't know its encoding, and didn't think I should care about it.
So he/I are only trying to use your principle as means to *read* from
to a QString, not the other way round.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt