New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tool to print code page information on Windows #1918
Conversation
With ninja built by CMake, running in Windows Console on Windows 10 1903+:
With ninja built by CMake, running in mintty on Windows 10 1903+:
With ninja built by
With ninja built by
With ninja built by either CMake or
|
+1 for the overall concept though. |
Sure it is. It's a |
You're quite right... I guess that didn't occur to me. It's so human-readable that it didn't occur to me that it didn't occur to me that it might be machine-readable too. +1 |
Group all the paragraphs together in the definition list entry.
Since commit 00459e2 (Use UTF-8 on Windows 10 Version 1903, fix ninja-build#1195, 2021-02-17), `ninja` does not always expect `build.ninja` to be encoded in the system's ANSI code page. The expected encoding now depends on how `ninja` is built and the version of Windows on which it is running. Add a `-t wincodepage` tool that generators can use to ask `ninja` what encoding it expects. Issue: ninja-build#1195
a1db7de
to
706e16b
Compare
I updated the branch to specify the tool's output format in the documentation. I also fixed formatting of the |
Thanks! |
We are now working on using this on our end - please see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5860. |
@bradking , @jhasse Code pages are super tricky. I have some feedback on the design: The concept of supporting multiple codepages is something we should move away in favor of using utf-8 as much as possible. For this reason, I think a better design would be to have ninja report whether it supports utf-8 as a boolean, yes or no. If yes, then its build configuration files should be utf-8. If no, then they should be ANSI, which is a system-global setting that can be retrieved by cmake. This avoids having implicit support for ninja reporting that it operates in a third codepage that is neither the system ANSI nor utf-8. The console code page is an extremely tricky piece of legacy and reporting it can only cause misinterpretations. What the console code page controls is how the console decodes the stdout of a program attached to it. When a program's output is redirected, there is no reason to honor the console code page and the Windows console team advocates always using utf-8 in this case for interoperability between the programs involved. This gets more complicated by the fact that not all programs honor this rule, and ninja pipes the output of other program to its own. Ninja can decide in which encoding to write its own output text, but it has no control over the encoding used by the programs it calls, which it pipes back to its own stdout. This is prone to leading to a mixed encoding stream. Moreover, the console code page from My suggestion is to treat the stdout of ninja as utf-8 at all times (even when that might not be true), which I think is what cmake already does. This might cause corruption in some ill-behaved programs, but is the only reasonable way to solve code page issues in the long run. Summary:
|
@MrTrillian thanks. I included the console code page for use in debugging encoding problems when running |
#1920 clarifies the documentation. |
@bradking If you're in a For the ANSI code page, |
@MrTrillian if
Not if they read the documentation updated as in #1920. |
@bradking In that case, the console window created for Relying on documentation is more brittle than transmitting targeted info. |
#1921 minimizes information in the output as proposed above. |
Since #1915,
ninja
does not always expectbuild.ninja
to be encoded in the system's ANSI code page. The expected encoding now depends on howninja
is built and the version of Windows on which it is running.Add a
-t wincodepage
tool that generators can use to askninja
what encoding it expects.Issue: #1195