Skip to content

Improve the build experience on Windows with non-English locales #138596

Backlog

Description

@Baka632

I am using Windows 11 with the system code page set to 936 (GBK).

During the build process, I encountered two encoding-related issues.

First, some characters are garbled at the beginning of the build:

Garbled characters at the beginning of the build output

Second, the build fails with C4819:

Build failure caused by C4819

As in #69781, many Mono files contain non-ASCII characters that trigger C4819. These files are valid UTF-8 but have no BOM, so MSVC decodes them using the system code page (936) instead of UTF-8.

There is a workaround: enable "Beta: Use Unicode UTF-8 for worldwide language support", and most of the encoding-related issues go away:

Build output after enabling UTF-8, with most encoding issues resolved

This fixes C4819, but it breaks compatibility with some legacy programs, and a few characters are still garbled:

A few characters are still garbled even with UTF-8 enabled

Can we improve the build scripts to avoid the garbled characters?

For the Mono files that trigger C4819, can we remove the non-ASCII characters, or should we fix the CMake files by specifying /source-charset:utf-8?

Activity

  1. added
    untriaged
    on Dec 1, 2026
  2. dotnet-policy-service commented on Dec 1, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-text-encoding
    See info in area-owners.md if you want to be subscribed.

  3. dotnet-policy-service commented on Dec 1, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/runtime-infrastructure
    See info in area-owners.md if you want to be subscribed.

  4. jkotas commented on Dec 1, 2026

    @jkotas
    Member

    Mono files

    Mono is no longer building in main. The offending files are going to be deleted soon. Nothing to do here.

    some characters are garbled at the beginning of the build:

    Are you interested in tracing down the source of the garbled output and proposing a fix?

  5. added
    needs-author-action
    on Dec 1, 2026
  6. dotnet-policy-service commented on Dec 1, 2026

    @dotnet-policy-service
    Contributor

    This issue has been marked needs-author-action and may be missing some important information.

  7. Baka632 commented on Dec 1, 2026

    @Baka632
    Author

    Thanks for your quick response.

    Mono is no longer building in main...

    Got it — I'll set the Mono part aside, since there is nothing to do there.

    Are you interested in tracing down the source of the garbled output and proposing a fix?

    Yes, I'm interested. This is my first time contributing to dotnet/runtime, though, so it may take me a while. I'll report back with what I find, and any pointers on where the build's opening output comes from would help a lot.

  8. removed
    needs-author-action
    on Dec 1, 2026
  9. Baka632 commented on Dec 2, 2026

    @Baka632
    Author

    This turned out to be more involved than I expected.

    1. Arcade's ExecWithRetries task doesn't set any encoding-related properties on the inner Exec task. I explicitly set UseUtf8Encoding=Always on it, and that fixed this part.

    2. NuGet Client's StaticGraphRestoreTaskBase task launches a child process but sets only the input encoding; it never sets StandardOutputEncoding on the ProcessStartInfo.

    I suspect there are more places with the same problem.

  10. huoyaoyuan commented on Dec 3, 2026

    @huoyaoyuan
    Member

    #90069

    There are some issues external, for example how different build tools are messing up with Windows console locale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Infrastructureuntriaged

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions