On Aug 26 09:30, Johannes Schindelin wrote:
> Hi Corinna,
> 
> On Wed, 26 Aug 2020, Corinna Vinschen wrote:
> 
> > On Aug 26 16:43, 宫大汉 via Cygwin-patches wrote:
> > > When Cygwin sets console titles on Win10 (has_con_24bit_colors && 
> > > !con_is_legacy),
> > > `WriteConsoleA` is used and causes an error if:
> > > 1. the environment variable of `LANG` is `***.UTF-8`
> > > 2. and the code page of console.exe is not UTF-8
> > >   1. e.g. on my Computer, it's GB2312, for Chinese text
> > >
> > >
> > > I've done some tests on msys2 and details are on 
> > > https://github.com/git-for-windows/git/issues/2738,
> > > and I filed a PR of 
> > > https://github.com/git-for-windows/msys2-runtime/pull/25.
> 
> Just in case you want to have a look at it, you can download the patch via
> https://github.com/git-for-windows/msys2-runtime/commit/334f52a53a2e6b7f560b0e8810b9f672ebb3ad24.patch
> 
> FWIW my original reviewer comment was: "why not fix wpbuf.send() in the
> first place?" but after having a good look around, that method seemed to
> be called from so many places that I "got cold feet" of that approach.
> 
> For one, I saw at least one caller that wants to send Escape sequences,
> and I have no idea whether it is a good idea to do that in the `*W()`
> version of the `WriteConsole()` function.

Yes, it is.  There's no good reason to use the A functions, actually.
They are just wrappers calling the W functions and WriteConsoleW
evaluates ESC sequences just fine (just given as UTF-16 chars).

> So the real question from my side is: how to address properly the many
> uses of `WriteConsoleA()` (which breaks all kinds of encodings in many
> situations because Windows' idea of the current code page and Cygwin's
> idea of the current locale are pretty often at odds).
> 
> The patch discussed here circumvents one of those call sites.
> 
> However, even though there have not been any callers of `WriteConsoleA()`
> in Cygwin v3.0.7 (but four callers of `WriteConsoleW()` which I suspect
> were converted to `*A()` calls in v3.1.0 by the Pseudo Console patches),
> there are now a whopping 15 callers of that `*A()` function in Cygwin
> v3.1.7. See here:
> [...]
> That cannot be intentional, can it? We should always thrive to use the
> `*W()` functions so that we can be sure that the expected encoding is
> used, right?

Takashi?  Any reason to use WriteConsoleA rather than WriteConsoleW?  If
at all, WriteConsoleA should only be used if it's 100% safe to assume
that the buffer only contains ASCII chars < 127.


Thanks,
Corinna

Reply via email to