none
Trouble Changing TTY/Console Locale via CHCP RRS feed

  • Question

  • A Windows Docker image I am creating is required to be able to change locale. By default, the Windows Server Core image uses code page 65001 (UTF-8 Unicode). After some research, I found that in order to change locale for a Windows system via command line interface, you use the command `chcp` followed by a code page number. Attempting to set this value to 437, the same code page used on my desktop installation of Windows, results in the following error message:
    `Invalid code page`

    To debug the issue, I attached WinDBG to a small C program that tries to change the locale via  SetConsoleOutputCP and found that SetTEBLangID, a function called within SetConsoleOutputCP, sets `errno` to 32 which is "Request is not supported." What exactly does this mean? Does this have something to do with the security of Windows containers? If so, is there a way to customize a containers security policy? Otherwise, is there any other way to change the code page/locale for the Windows Server Core Docker image?

    -Douglas
    Tuesday, August 15, 2017 9:54 PM

All replies

  • There is no console to change the code page for. Interactively attaching to a container just effectively streams stdin, stdout, and stderr to the host console. The container doesn't see or have a console to fiddle with.

    Why do you need to change the code page?

    Wednesday, August 16, 2017 4:02 AM
  • Because the default code page for the container is 65001, Python 2.7 fails to function correctly unless the environmental variable `PYTHONIOENCODING` is set to `utf-8`. After doing this, Python scripts will run, however, any and all IO is now encoded as UTF-8 by default which breaks backwards compatibility with scripts that expect default IO to be ANSI. Is the default codepage for Windows Server Core 65001? Additionally, is there any reason why one can freely change codepages on a desktop installation of Windows but not within the container? Finally, one last clarification, the codepage of PowerShell and CMD on the host are set to 437, not 65001 which the container defaults as.

    Thanks,

    Douglas

    Thursday, August 17, 2017 8:28 PM
  • I suspect this is UTF-8 due to the underlying stream coming out, but let me check tomorrow. Interesting issue you got there.
    Monday, August 21, 2017 8:09 AM
  • Hey Douglas,

    I'm still tracking down what's up with the default, but in the meantime, setting PYTHONIOENCODING=cp437 should get you back up and running without problems.

    Can you confirm?


    Monday, August 21, 2017 8:28 PM