On Fri, Jan 16, 2026 at 02:31:43PM +0200, Eli Zaretskii wrote:
> > Date: Fri, 16 Jan 2026 00:16:47 +0100
> > From: Patrice Dumas <[email protected]>
> > Cc: [email protected], [email protected]
> >
> > > > #ifdef _WIN32
> > > > if (!locale_encoding)
> > > > {
> > > > unsigned cp = GetACP ();
> > > > xasprintf (&locale_encoding, "cp%u", cp);
> > > > }
> > > > #endif
> > > >
> > > > Should there be a change to that code too?
> > >
> > > I think texi2any uses the locale's encoding for different purposes,
> > > but it cannot do any harm to report codepage 65001 as "UTF-8", so yes.
> >
> > What would be the change to Perl equivalent code? The current code is:
> >
> > if (!defined($locale_encoding) and $^O eq 'MSWin32') {
> > eval 'require Win32::API';
> > if (!$@) {
> > Win32::API::More->Import("kernel32", "int GetACP()");
> > my $CP = GetACP();
> > if (defined($CP)) {
> > $locale_encoding = 'cp'.$CP;
>
> Yes, but I would (a) import GetConsoleOutputCP as well, and (b) use
> GetConsoleOutputCP in preference to GetACP, if the former returns
> non-zero. That's because on Windows it is possible to change the
> encoding understood by the terminal independently of the system
> locale's codeset (which is what GetACP returns).
>
> Note that the preference of GetConsoleOutputCP is only for text that
> will eventually be output to the terminal. In other cases, such as
> encoding/decoding of file names or decoding system messages and values
> of environment variables, the value returned by GetACP is the right
> one.
We already have different encodings set to the locale, but it is not
completly clear to me where GetConsoleOutputCP or GetACP should be used.
Could you please correct and complete the following information:
* decode command-line, including file names passed on the command line
we would like to decode (sometime we do not decode file names) -> ?
* decode environment variables (we do not decode file names
passed as environment variables in some cases) -> GetACP
* error and warning messages translations encoding -> GetACP
* encode command line before executing the command line -> ?
* error and warning messages output encoding -> GetConsoleOutputCP
* encode input file names and output file names on the filesystem -> GetACP
Another information I would need is the equivalent in Perl of
determining that the console page is UTF-8. In C it is like:
UINT cp = GetACP ();
if (cp == CP_UTF8)
....
What the (cp == CP_UTF8) comparison should be on the string returned by
GetACP or GetConsoleOutputCP?
--
Pat