none
Codepages in servercore/nanoserver

    Question

  • We have a legacy application that we are trying to get running in Docker under a Windows Server Core based container.

    This has a dependency on mixed codepages for combined Japanese/English support that we haven’t been able to get working under the Windows image. Whatever we do, the active codepage seems to be set to 65001 (UTF-8), under which our application doesn’t behave as we require. It also doesn’t inherit any codepage from the host environment. 

    Some reproduction instructions to our issue are as follows:

    Running on Windows Server 2016:

    •          Docker pull microsoft/windowsservercore
    •          Run: docker run –it microsoft/windowsservercore cmd.exe
    •          Run: mode CON: CP /status – this returns 65001 (UTF-8)
    •          Run the powershell command: [System.Text.Encoding]::GetEncodings() shows that lots of code pages are known about, and running GetEncoding(932) shows that the codepage we are interested is indeed there.
    •          Run either of: chcp 932 or mode CON: CP select=932
    •          This produces an error about an invalid code page.

    In nanoserver, chcp and mode commands seem to have been removed completely. From this I’m hypothesising that chcp and changing the codepage just doesn’t work in a container. Is anyone able to confirm?

    Note we have tried various options with no positive effect, e.g:

    Monday, January 8, 2018 11:08 AM

All replies

  • Does this work in plain server core installation in a first place?
    Monday, January 8, 2018 4:18 PM
  • A very interesting question... I will investigate further!
    Monday, January 15, 2018 10:24 AM
  • I've tried a few things on this, experimenting with different language/host/tags/ options...

    English host
    --- chcp 932 fails with "invalid code page"
    JP host
    --- code page set to 932
    English servercore DOCKER image
    --- CHCP set to 65001 (default) - cannot set to 932.
    JP servercore DOCKER image
    --- CHCP set to 65001 (default) - cannot set to 932.

    So whatever I do, it seems the codepage in a container is set to 65001 (UTF-8). I cannot change it to 932.

    On servercore container, running "type" on a file containing Japanese characters, does not display the Japanese characters correctly. It works fine on the host. For reference, I am using the Japanese container tag:

    microsoft/windowsservercore:10.0.14393.2007_ja-jp

    Thursday, January 18, 2018 11:12 AM
  • The underlying streams going into/coming out of docker are UTF-8 so chcp, mode, etc won't do you any good. What does your application do that requires this? Does it have a textual user interface that you need to interact with?

    If it's python code, you can at least override IO encoding using the PYTHONIOENCODING environment variable. A little more details about your app would go a long way to figuring out a workaround.

    Wednesday, January 24, 2018 6:56 AM
  • @WithinRafael - Yeah, there's quite a lot about python and Docker on the internet, but we're not using Python in this case...

    I think as a very basic use case, this I would expect to function: 

    On servercore container, running "type" on a file containing Japanese characters, does not display the Japanese characters correctly. It works fine on the host. For reference, I am using the Japanese container tag:

    microsoft/windowsservercore:10.0.14393.2007_ja-jp

    Wednesday, February 7, 2018 2:54 PM
  • In my case - not working to change to cp1251 (Cyrillic)

    Using microsoft/windowsservercore:10.0.14393.2608_ru-ru - not working too.

    Thursday, November 29, 2018 4:46 AM
  • Hi, I don't have an environment that can handle Russian/Cyrillic characters to hand, but I've done some initial testing using Server 2019 as my host OS and mcr.microsoft.com/windows/servercore:ltsc2019 - version 10.0.17763.134, as the container and in my case it seems to be working much better now for Japanese language. You may want to give it another go with a more recent Windows version, Server 2019 if you're able to do so (or perhaps 2016 "windows server 1809"...?

    From what I've found, you'll need to install the correct language pack on the host, change the Codepage on the host, and in the container. 

    Thursday, November 29, 2018 4:44 PM
  • >/servercore:ltsc2019 - version 10.0.17763.134, as the container and in my case it seems to be working much better now for Japanese language.

    Same problems at:

    Windows Server 2019

    microsoft/dotnet-framework:3.5-runtime-windowsservercore-ltsc2019


    Thursday, April 18, 2019 2:52 AM