Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-13303

There should be a QTextCodec for the Windows console code page

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Open
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 4.6.3, 4.7.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Localized Windows versions.

      Description

      There is a problem with localized version of Windows. Many standard console tools write their output using OEM charset which does not same with local system charset. For example, for russian Windows, local 8-bit code page is CP1251, while the "console codepage" is CP866.
      So, when reading and writing to QProcess I should convert QString to CP866 encoding.

      Solutions:
      1. create function QTextCodec::codecForConsole() which will return special value on Windows, and codecForLocale() in other operation systems.
      We need to create big switch() for http://msdn.microsoft.com/en-us/library/dd317756(v=VS.85).aspx values which will convert microsoft values to MIB values. After which we shoudl return QTextCodec::codecForMib(...);
      2. Implement QString::fromConsoleCP() and QString::toConsoleCP() which will use QTextCodec::codecForConsole() by default.
      Note, that in theory, GetConsoleCP() and GetConsoleOutputCP() may return different encodings. QTextCodec::codecForConsole() should handle this.

      Additional info:
      According to MSDN, to get console code page number, I should call WinAPI function ::GetConsoleCP() for output charset and ::GetConsoleOutputCP() for input charset. Surprisingly, both functions return 0 on my system, but fortunately theres is ::GetOEMCP() which return correct codepage number

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              socketpair@gmail.com Коренберг Марк
              Votes:
              10 Vote for this issue
              Watchers:
              12 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes