[PATCH 3/3] fhandler_pty_slave::setup_locale: respect charset == "UTF-8"
Corinna Vinschen
corinna-cygwin@cygwin.com
Thu Sep 10 14:04:07 GMT 2020
Hi Takashi,
On Sep 10 09:15, Takashi Yano via Cygwin-patches wrote:
> On Wed, 9 Sep 2020 09:21:23 +0200
> Corinna Vinschen wrote:
> > Takashi, does the patch from
> > https://cygwin.com/pipermail/cygwin-developers/2020-August/011951.html
> > still apply to the latest from master? Question is, shouldn't the
> > Windows calls setting the codepage be only called if started from
> > child_info_spawn::worker for non-Cygwin executables?
>
> I'd propose the patch:
>
> diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
> index 37d033bbe..95b28c3da 100644
> --- a/winsup/cygwin/fhandler_tty.cc
> +++ b/winsup/cygwin/fhandler_tty.cc
> @@ -1830,7 +1830,11 @@ fhandler_pty_slave::setup_locale (void)
> extern UINT __eval_codepage_from_internal_charset ();
>
> if (!get_ttyp ()->term_code_page)
> - get_ttyp ()->term_code_page = __eval_codepage_from_internal_charset ();
> + {
> + get_ttyp ()->term_code_page = __eval_codepage_from_internal_charset ();
> + SetConsoleCP (get_ttyp ()->term_code_page);
> + SetConsoleOutputCP (get_ttyp ()->term_code_page);
> + }
> }
>
> void
>
> However, Johannes insists setting codepage for non-cygwin apps
> even when pseudo console is enabled, which I cannot agree.
>
> Actually, I hesitate even the patch above, however, it seems to
> be necessary for msys apps in terms of backward compatibility.
If we do as above, doesn't that mean the invocation of convert_mb_str in
fhandler_pty_master::accept_input, as well as the second invocation of
convert_mb_str in fhandler_pty_master::pty_master_fwd_thread are
redundant? Both are only called if get_ttyp ()->term_code_page differs
from the input or output console codepage. Given the above setting of
the console CP to term_code_page, this would never be the case, right?
Corinna
More information about the Cygwin-patches
mailing list