Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Console and Qt Unicode Text
    text
    copied!<p>I spent a whole day trying to figure this out with no luck. I looked Everywhere but no luck with working code.</p> <p>OS: Win XP Sp2 IDE &amp; FRAMEWORK: C++, Qt Creator 2.0.</p> <p>I am trying to output some unicode (UTF-8) text to the windows console but all I see is gibberish in place of the unicode chars. I know the win console does support unicode (since win 2000)... at least according to Wikipedia and many on the net but I don't see how to make it work with Qt. Most "solutions" I've seen (haven't seen many) use C++ and WInAPI tech... which I can't use because that is not the Qt way. I am using QStrings and Qt!</p> <p>Code is bellow. I took out all the different things I tried to keep the code simple for the post. Hope someone can get the code to work.</p> <pre><code>#include &lt;QtCore/QCoreApplication&gt; #include &lt;QString&gt; #include &lt;QTextStream&gt; #include &lt;QDate&gt; #include &lt;QFile&gt; using namespace std; int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QTextStream qin(stdin); QTextStream qout(stdout); //The last 2 chars in QString each need a double slash for an accent. QString szqLine = QString::fromUtf8("abc áéüóöú őű"); //I want this text console output to be in red text color. qout &lt;&lt; "Bellow are some unicode characters: " &lt;&lt; endl; //The Win XP console does not display the unicode chars correctly!! //The cosole does not display unicode chars even though it is capable //according to wikipedia. I just don't know how with Qt. //I want this text output in white(or default font color, not red.) qout &lt;&lt; szqLine &lt;&lt; endl; //Would be nice to get some unicode input from console too. qout &lt;&lt; "Write some unicode chars like above: " &lt;&lt; endl; QString szqInput; szqInput = QString::fromUtf8(qin.readLine()); qout &lt;&lt; "You wrote: " &lt;&lt; endl; qout &lt;&lt; szqInput &lt;&lt; endl; return app.exec(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload