public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: pty: Prevent garbled output for existing non-cygwin apps.
Date: Fri, 11 Sep 2020 12:09:30 +0000 (GMT)	[thread overview]
Message-ID: <20200911120930.04BB63986815@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=232fde0e76db14fc59912d0022b72c7739f1d598

commit 232fde0e76db14fc59912d0022b72c7739f1d598
Author: Takashi Yano via Cygwin-patches <cygwin-patches@cygwin.com>
Date:   Fri Sep 11 19:54:40 2020 +0900

    Cygwin: pty: Prevent garbled output for existing non-cygwin apps.
    
    - If pseudo console is disabled, non-cygwin apps do not detect
      console device. In this case, some apps output UTF-8 regardless
      of the locale setting. At least git-for-windows, rust-based apps
      and node.js do that. This patch provides backward compatibility
      as default behaviour by setting console codepage to the charset of
      the locale. Even in the cases above, garbled output is prevented
      with this patch in most cases because mintty uses UTF-8 by default.
    
      I beleave this is not really a problem in cygwin side but that in
      app side, however, some users complain about garbled output with
      existing apps in MSYS2 (which is based on cygwin) in which pseudo
      console is disabled by default.

Diff:
---
 winsup/cygwin/fhandler_tty.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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


                 reply	other threads:[~2020-09-11 12:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200911120930.04BB63986815@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).