[Interest] Qt/Windows: QProcess and wide characters

Rainer Wiesenfarth Rainer_Wiesenfarth at trimble.com
Fri Mar 15 19:06:45 CET 2013


I have a problem on Windows with QProcess and a child process which 
prints out wide characters on stdout: QProcess does not get any output 
of the child if the child uses _setmode(_fileno(stdout),_O_U16TEXT) to 
get wide characters on output. This happens both on Qt 4.8.0 and on Qt 
5.0.0.

To reproduce:
- unzip the attached source
- assert that your command prompt uses a TrueType font which contains 
wide characters
- in consoleTest, use qmake followed by nmake
- run parent\release\parent.exe
- optional: run child\release\child.exe with and without a parameter

This runs the child twice. Once with plain ASCII output and once with 
wide character output. Only the output of the first run is captured by 
the parent, while the output of the second run gets lost.

Is this a bug in Qt? A restriction of Qt on Windows? Does anybody have a 
workaround?

This is the output I get:

D:\Develop\Rainer\QtBugs\consoleTest>child\release\child.exe
stdout using plain ASCII: no idea what the russian characters stand for.
stderr using plain ASCII: no idea what the russian characters stand for.
cout using plain ASCII: no idea what the russian characters stand for.
cerr using plain ASCII: no idea what the russian characters stand for.

D:\Develop\Rainer\QtBugs\consoleTest>child\release\child.exe param
stdout using wide characters: фывапр
stderr using wide characters: фывапр
wcout using wide characters: фывапр
wcerr using wide characters: фывапр

D:\Develop\Rainer\QtBugs\consoleTest>parent\release\parent.exe
Starting child process (no parameter) 
D:/Develop/Rainer/QtBugs/consoleTest/child/release/child.exe
stdout using plain ASCII: no idea what the russian characters stand for.
cout using plain ASCII: no idea what the russian characters stand for.
stderr using plain ASCII: no idea what the russian characters stand for.
cerr using plain ASCII: no idea what the russian characters stand for.
Child process (first run) done.
Starting child process (with parameter) 
D:/Develop/Rainer/QtBugs/consoleTest/child/release/child.exe
Child process (second run) done.

Best Regards / Mit freundlichen Grüßen
Rainer Wiesenfarth

-- 
Software Engineer | Trimble Imaging Division
Rotebühlstraße 81 | 70178 Stuttgart | Germany
Office +49 711 22881 0 | Fax +49 711 22881 11
http://www.trimble.com/geospatial/ | http://www.inpho.de/

Trimble Germany GmbH, Am Prime Parc 11, 65479 Raunheim
Eingetragen beim Amtsgericht Darmstadt unter HRB 83893,
Geschäftsführer: Dr. Frank Heimberg, Hans-Jürgen Gebauer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: consoleTest.zip
Type: application/x-zip-compressed
Size: 3543 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130315/1fbb1fc7/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4495 bytes
Desc: S/MIME Kryptografische Unterschrift
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130315/1fbb1fc7/attachment-0001.bin>


More information about the Interest mailing list