Hi everybody!
Everything fine with QProcess but the result text I have from Windows looks to not be UTF-8.
Is there a way to have accurate UTF-8 from "readAllStandardOutput"?
If possible I'm looking for a cross platform solution.
Thanks a lot!
Hi everybody!
Everything fine with QProcess but the result text I have from Windows looks to not be UTF-8.
Is there a way to have accurate UTF-8 from "readAllStandardOutput"?
If possible I'm looking for a cross platform solution.
Thanks a lot!
Since the console on windows does not output utf-8 encoded but locale aware strings, you have to use QString::fromLocal8Bit().
I tried but I can't see correctly accent characters and instead there is a wrong character.
I get the result from CMake to print the standard output and error output.
Calling CMake from a terminal shows correctly the accent characters so it must be possible to get this full data correctly and have it in UTF-8...
Last edited by Alundra; 7th February 2021 at 12:56.
How do you check? Use a QMessageBox instead stdout and show some code.
Here the code used to call cmake:
I added a breakpoint to see the value of of the allStandardOutput and I can see also in Visual Studio the data inside doesn't have the accent but is replaced by ','.Qt Code:
QProcess compileProcess; compileProcess.start("cmake", {"--build", ".", "--config", "Release"}); compileProcess.waitForFinished();To copy to clipboard, switch view to plain text mode
Here a screenshot of the result from the breakpoint:
UnicodeProblem.jpg
You can see at the end of the image, the text should be "Tous droits réservés."
It's like the data is in ASCII so any conversion code will never end to something different. Outside the ASCII range got replaced by a character.
Last edited by Alundra; 7th February 2021 at 13:38.
Open standard CMD window and run CHCP. You will see the current codepage setting for the console.
The result is: 850
https://docs.microsoft.com/en-us/win...-commands/chcp
Gives: 850 = Multilingual (Latin I)
But I already tried to call QString::fromLatin1 and he bypass the accents.
I also tried to put the text in a QMessageBox, same results:
Qt Code:
To copy to clipboard, switch view to plain text mode
Did you actually read my first post? I told you that you have to use QString::fromLocal8Bit() to convert your input from QProcess to a QString. Now you're either using a plain QByteArray or QString:::fromLatin1() for no reason...
Bookmarks