Skip to content

Commit a510f53

Browse files
committed
wincodepage: minimize to indicate UTF-8 or not
The ANSI code page identifier is more information than generator programs actually need. The encoding of `build.ninja` is always either UTF-8 or the system-wide ANSI code page. Reduce the output to provide no more information than the generator programs need. The Console code page can be obtained in other ways, so drop it.
1 parent 1a80150 commit a510f53

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

doc/manual.asciidoc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,21 @@ file. _Available since Ninja 1.10._
308308
if they have one). It can be used to know which rule name to pass to
309309
+ninja -t targets rule _name_+ or +ninja -t compdb+.
310310
311-
`wincodepage`:: available on Windows hosts. Prints the ANSI code page
312-
used by `ninja`, whose encoding is expected in `build.ninja`. Also prints
313-
the Console code page for reference. The output has the form:
311+
`wincodepage`:: Available on Windows hosts (_since Ninja 1.11_).
312+
Prints the Windows code page whose encoding is expected in the build file.
313+
The output has the form:
314314
+
315315
----
316-
ANSI code page: %u
317-
Console code page: %u
316+
Build file encoding: <codepage>
318317
----
319318
+
320-
where each `%u` is an integer code page identifier, expressed in decimal.
321-
_Available since Ninja 1.11._
319+
Additional lines may be added in future versions of Ninja.
320+
+
321+
The `<codepage>` is one of:
322+
323+
`UTF-8`::: Encode as UTF-8.
324+
325+
`ANSI`::: Encode to the system-wide ANSI code page.
322326
323327
Writing your own Ninja files
324328
----------------------------

src/ninja.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,7 @@ int NinjaMain::ToolWinCodePage(const Options* options, int argc, char* argv[]) {
648648
printf("usage: ninja -t wincodepage\n");
649649
return 1;
650650
}
651-
printf("ANSI code page: %u\n", GetACP());
652-
printf("Console code page: %u\n", GetConsoleOutputCP());
651+
printf("Build file encoding: %s\n", GetACP() == CP_UTF8? "UTF-8" : "ANSI");
653652
return 0;
654653
}
655654
#endif
@@ -1023,7 +1022,7 @@ const Tool* ChooseTool(const string& tool_name) {
10231022
{ "urtle", NULL,
10241023
Tool::RUN_AFTER_FLAGS, &NinjaMain::ToolUrtle },
10251024
#ifdef _WIN32
1026-
{ "wincodepage", "print the Windows ANSI code page identifier",
1025+
{ "wincodepage", "print the Windows code page used by ninja",
10271026
Tool::RUN_AFTER_FLAGS, &NinjaMain::ToolWinCodePage },
10281027
#endif
10291028
{ NULL, NULL, Tool::RUN_AFTER_FLAGS, NULL }

0 commit comments

Comments
 (0)