From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 42283386F429 for ; Tue, 1 Sep 2020 10:03:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 42283386F429 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Johannes.Schindelin@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1598954621; bh=jEiT/gFxL6tmauS3pK4RraeCzkFibTwrlvXfvMEyUzU=; h=X-UI-Sender-Class:Date:From:To:cc:Subject:In-Reply-To:References; b=YpzRhMGfXQWNWsoNB7O1bNtV48DvY8GV6o8tftFAGK+dVd6gWBcS1mf/wWguMbmU6 if3nUe0TmlJuDi7sQShn+PhZNpGe6/CSbyaje6dw0bOnljBiQs0oNOj8vcT8itMX/B uo/8x6dU46SySY4I0DpKh/zeKLEFVRyRzil9motY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [172.18.169.176] ([89.1.214.118]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MOiDX-1jwJjH38kp-00QFjz; Tue, 01 Sep 2020 12:03:40 +0200 Date: Tue, 1 Sep 2020 08:32:30 +0200 (CEST) From: Johannes Schindelin X-X-Sender: virtualbox@gitforwindows.org To: Takashi Yano cc: cygwin-developers@cygwin.com Subject: Re: New implementation of pseudo console support (experimental) In-Reply-To: <20200901182303.76c0ab7a52553910b540f2bc@nifty.ne.jp> Message-ID: References: <20200819134156.GP3272@calimero.vinschen.de> <20200820170210.e066c8ad933ca31061130ba9@nifty.ne.jp> <20200831231253.332c66fdddb33ceed5f61db6@nifty.ne.jp> <20200831235325.c26c1a75e4cec737e793c91c@nifty.ne.jp> <9f0e8248-cc3b-b5a8-0af5-43dbdf079478@towo.net> <1104c24d-49ea-96b9-30cb-acd4460108ab@towo.net> <20200831193736.GG3272@calimero.vinschen.de> <20200901182303.76c0ab7a52553910b540f2bc@nifty.ne.jp> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 X-Provags-ID: V03:K1:6pzcn3JoHSCpDH7F9bhWgi0PdCRfBmVorjMkpNGETxMN15SdTAJ aUoEsyjVaOcG6VemF2X+IR53Kh6S83DC4LoIo/fpqeCE3PcTtv5+kMEcm2Q6F9qfiPlzRKc O6w5POzOOGREIky+m1Wz6RbTcwoTIHUdPYek6tSgF5q93yuU66lqHf+pqVTZnSTcJo6qth6 16FPVxPXeyljuvQoOPw2g== X-UI-Out-Filterresults: notjunk:1;V03:K0:XTQloMVZ564=:A0Ve7xDrqKJH5T8FSR6EZn UBvVybT4wm7i206EfMLlPHxk8xpJyDVZQNCAHKVo9b5kT6Am/A1XwpQOhfsDCYziF+pYaieal 4ZeKAKX61DzR6t7A7dSGx0yDbiqWen1MvuTDb78p0BBbtN7skc7C+ltJMrdHVO0U00T6KfDgr 2sg/9SYjaYz3UcsN7ICM9wk37N+IEt3fHnad5KbEpeDkq7eceCXzeiTZ6u+U9WyWkJ/5Q9xEk 1NzH/FSOxj1vv15A+UiQl6soiEIC1vqJ2pERChjK9czMuCpZ8KmwaxDKynWsQgf4v4pJHvyL8 zNkKMR6O/Xw/c8IT60C2W0kv6bU+1HjCEBZpWNA8FZg49i2aALLVe4AZhUXm2Y8At/0GhatsY LHDLVSmnQbLd9rIi+BKFW1ttbiueRbADAUCD1Il5M4GZ5jFhZIznyOJ9K7g1ZbjOoKLy6Hf9l FKi9mjFRcjQ2RCjShV/lf2CCsYDPTScC7Nyhgmc6Jwj+vBpePzFXBz+hafaIssoRHSvZ677kO 52z/gYCYawn68ty/nPa7yBcFft+ey+W6pxz10Qp/1UHU6Z6wpqJ40rXOlV+XqMH3GHSIJsris tLOEvlaDVqmGwoUDmTkZQ+hGBbTt025WDB4G6dVgAER3HoTCfQ3qqvg/+QNbUxPqpEOse0FNY 5CET3NiD98c4Z540a5YzMTTpzB36wiQbaE2wA3ZX+NDZ+2C9uVbwbPEx4mfh7z9V5U4GSLxdO ZBLf1oPJnfi1Ne3Q96BkoREC67aYYvSU3QDXGKDQCPnrd0EQ9ToGG7+GdZsaehquTKLlvULsj N/ZfhX18LRFTbWmyXjJTcWudM2dnVs8R9aPV4SQnnYf6SnslC2WPUU+x9IIS4uZLSgcoEax7w Yfj522SnZC++dEmYDaS3MfEGgSkfhcLv4ut3pMuVw2mVlPceLl4RWKsI379QuRaK7JzdJPXsk QUobtSQ4I7A+21nX65CEZHId8YOuO4Yabi28vMTvjohOXkpvrnEva9sPbAnm2tHaLsC1laHOk co9jb8HZL2MB40hyFbfGPiWbI9xIVefQkqmoHZMK+OHesBGGiNp4kk2Io6uc0Fsv3X9Cglept Cr+3QUXvEu4we/+UyNAVSezG1FJZ8/f+tND3RAoazWI4EC+pT1eR4+FRwB7xvvgcPgI1G4q1m LRukYDPzzu5CqTtV6c8J+iF4M47S4hbOj4Zqkza34nz7kFq9bfInGhxEsDv9bxOUN4aMlgT+Z yxneiyMlzCfmApLG1S8UX7G+gcTNNKoJOLpFcfA== X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, BODY_8BITS, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2020 10:03:49 -0000 Hi Takashi, On Tue, 1 Sep 2020, Takashi Yano via Cygwin-developers wrote: > On Tue, 1 Sep 2020 06:46:53 +0200 (CEST) > Johannes Schindelin wrote: > > > -- snip -- > > diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tt= y.cc > > index 43eebc174..65b4d45fa 100644 > > --- a/winsup/cygwin/fhandler_tty.cc > > +++ b/winsup/cygwin/fhandler_tty.cc > > @@ -2867,7 +2867,16 @@ fhandler_pty_slave::setup_locale (void) > > char charset[ENCODING_LEN + 1] =3D "ASCII"; > > LCID lcid =3D get_langinfo (locale, charset); > > > > - /* Set console code page form locale */ > > + /* Special-case the UTF-8 character set */ > > + if (strcasecmp (charset, "UTF-8") =3D=3D 0) > > + { > > + get_ttyp ()->term_code_page =3D CP_UTF8; > > + SetConsoleCP (CP_UTF8); > > + SetConsoleOutputCP (CP_UTF8); > > + return; > > + } > > + > > + /* Set console code page from locale */ > > if (get_pseudo_console ()) > > { > > UINT code_page; > > -- snap -- > > I don't think you do right thing. Your first test case makes > garbled output in command prompt, therefore output in cygwin > should be the same. > > I believe the correct maner as Windows programs are such as: > > [Code A] > #include > #include > > int main(){ > int origcp =3D GetConsoleOutputCP(); > SetConsoleOutputCP(CP_UTF8); > puts("=D0=9F=D1=80=D0=B8=D0=B2=D0=B5=D1=82 =D0=BC=D0=B8=D1=80! Hello w= orld!"); > SetConsoleOutputCP(origcp); > return 0; > } > > [Code B] > #include > #include > > int main(){ > setlocale (LC_ALL, ""); > _putws(L"=D0=9F=D1=80=D0=B8=D0=B2=D0=B5=D1=82 =D0=BC=D0=B8=D1=80! Hell= o world!"); > return 0; > } > > if the source code is in UTF-8 coding. Or compiled > with -fexec-charset=3Dutf-8. > > Both work as expected in command prompt as well as > in current cygwin. Sorry for being unclear. The test program was only provided in order to provide a working reproducer for an issue we see in _many_ instances. In many cases, I am _not_ at liberty (nor do I have the time) to recompile the programs. And even if what you say is true, the fact is that there are many existing executables out there that do not call `SetConsoleOutputCP()`. All of them would be helped with my patch (provided that `LANG` or friends define the charset to be `UTF-8`). Are they buggy? Yes. Does the patch help the users? Also yes. But what I am really a lot more interested in is your answer to the question why the code path behind `disable_pcon` does anything different from what v3.0.7 did. I think that really is important to understand. Without that information, I am not sure whether my patch is hiding an even bigger problem. So please, please, please, can I have an answer to that? Why did the non-Pseudo Console code path change? And in what way? Ciao, Johannes