Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Non-Ascii characters in Windows console
Forum Update on Monday, May 27th 2025

Non-Ascii characters in Windows console

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    s.frings
    wrote on 28 Sept 2010, 10:34 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      s.frings
      wrote on 28 Sept 2010, 12:41 last edited by
      #2

      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?

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yogesh
        wrote on 29 Sept 2010, 12:49 last edited by
        #3

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          s.frings
          wrote on 29 Sept 2010, 18:37 last edited by
          #4

          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.

          1 Reply Last reply
          0

          1/4

          28 Sept 2010, 10:34

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved