Non-Ascii characters in Windows console



  • Hello,

    I have a problem using non-ascii characters in the windows console (cmd shell).

    @QString s=QString::fromUtf8("Hallo äöüß");
    cout << qPrintable(s) << endl;@

    I can compile this UTF8 encoded source file and run this under Linux properly. But on windows it produces garbage output. Also the following produces the same garbage output:

    @QString s=QString::fromUtf8("Hallo \u00E4 \u00F6 \u00FC \u00DF");
    cout << qPrintable(s) << endl;@

    Output: Hallo õ ÷ ³ ▀

    All four characters are surely supported by the cmd shell, so I do not understand why both works fine under Linux only.



  • I repeated the same test under Windows 7, which produced the same result.

    When I call
    @QTextCodec::setCodecForLocale(QTextCodec::codecForName("IBM 850"));@

    before writing to the console, the output looks fine. Could it be possible that the automatic detection of console encoding does not work in Windows? How can I programmatically find out what encoding is the correct one?



  • I think the required font is not available on your windows machine.



  • Yes, the cmd shell does obviously not support Latin1. I can change the font using the chcp command, but no avaiable font matches Latin1.

    But QT supports encoding to the console encoding, which is "IBM 850" in my case. What I need is a method that tells me the current encoding of the console font, so I can set the correct encofing in my program.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.