[Qt-interest] why .fromLocal8Bit() is needed

chandrasekar wagmare sekarwagmare at gmail.com
Fri Mar 20 09:32:38 CET 2009


thanks for reply first ....
my process will output some text like "joystick failed due to .... problem"
.. in this case what shall i use :fromAscii.? or any thing else ...?

On Fri, Mar 20, 2009 at 1:34 PM, Andreas Pakulat <apaku at gmx.de> wrote:

> On 20.03.09 12:52:47, chandrasekar wagmare wrote:
> > hi friends,
> >         i try all the assistant documents but cant find ... what is the
> > difference between this two .. to get readyReadStandardError() from
> > QProcess()
> >           1.
> >               QString path = process.readAllStandardError();
> >               path = outputtextedit->setText(path);
> >
> >           2.
> >                QByteArray newData = process.readAllStandardError();
> >              QString text = outputTextEdit->toPlainText()
> >                                       + QString::fromLocal8Bit(newData);
> >                     outputTextEdit->setPlainText(text);
> >
> > why we need to convert QString as like 2 nd one .... what will happen if
> i
> > use 1 st condition
>
> You'll get broken text if the process sends anything but plain ascii. See
> the QString methods that take a QByteArray as input, they all use
> QString::fromAscii internally (or if you're lucky fromLatin1 which would
> work for some non-ascii characters).
>
> Even fromLocal8Bit might be wrong, if your external process always outputs
> in some specific 8 bit encoding (for example it could always print out in
> utf8) or some other encoding. Basically you need to find out how your
> external process prints out its text, wether you maybe can force it to use
> some specific encoding.
>
> Andreas
>
> --
> You will be awarded the Nobel Peace Prize... posthumously.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



-- 
CHANDRU
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090320/195bfe02/attachment.html 


More information about the Qt-interest-old mailing list