[PATCH 3/3] fhandler_pty_slave::setup_locale: respect charset == "UTF-8"
Corinna Vinschen
corinna-cygwin@cygwin.com
Fri Sep 11 09:23:02 GMT 2020
On Sep 11 11:05, Corinna Vinschen wrote:
> On Sep 10 21:34, Takashi Yano via Cygwin-patches wrote:
> > On Thu, 10 Sep 2020 09:15:00 +0900
> > Takashi Yano via Cygwin-patches <cygwin-patches@cygwin.com> wrote:
> > > 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.
> >
> > I found that output of Oracle java.exe and javac.exe are garbled
> > if the patch above is applied. This is because java.exe and javac.exe
> > output SJIS code unconditionally in my environment.
> >
> > OTOH, rust-based program such as cargo and ripgrep output UTF-8
> > unconditionally. node.js also seems to output UTF-8 string by
> > default.
> >
> > I think there is no way for both apps to work properly if pseudo
> > console is disabled. As far as I tested, both of them works when
> > pseudo console is enabled. IMHO, the best way to achieve maximum
> > compatibility, is enabling pseudo console, which is disabled in
> > MSYS2 by default.
> >
> > As for the case with pseudo console disabled:
> >
> > If backward compatibility is important, we should apply the patch
> > above. If compatibility with the behaviour in command prompt is
> > important, we should leave the codepage to the system default.
>
> Pseudo console is probbaly the way to go in future anyway. For
> older OSes and older apps, we might better opt for backward compat.
> I'll apply your patch for the time being.
Oh, right, can you please send it again in git style?
Thanks,
Corinna
More information about the Cygwin-patches
mailing list