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

There should be a QTextCodec for the Windows console code page



    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.6.3, 4.7.0
    • None
    • Localized Windows versions.


      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.

      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


        Issue Links

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



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



                Gerrit Reviews

                  There are no open Gerrit changes