]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: pty: Set console code page only if pseudo console is enabled.
authorTakashi Yano <takashi.yano@nifty.ne.jp>
Fri, 10 Jan 2020 11:47:12 +0000 (20:47 +0900)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 14 Jan 2020 16:19:49 +0000 (17:19 +0100)
- Input UTF-8 chars are garbled in ConEmu with cygwin connector if
  the environment does not support pseudo console. This patch fixes
  the issue.

winsup/cygwin/fhandler_tty.cc

index 983e058dc4791a5e10633193e8e4c1c20ec5228a..fff5bebe325f8e177ba679f5d954cee76b8adda0 100644 (file)
@@ -2626,15 +2626,18 @@ fhandler_pty_slave::setup_locale (void)
   LCID lcid = get_langinfo (locale, charset);
 
   /* Set console code page form locale */
-  UINT code_page;
-  if (lcid == 0 || lcid == (LCID) -1)
-    code_page = 20127; /* ASCII */
-  else if (!GetLocaleInfo (lcid,
-                          LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER,
-                          (char *) &code_page, sizeof (code_page)))
-    code_page = 20127; /* ASCII */
-  SetConsoleCP (code_page);
-  SetConsoleOutputCP (code_page);
+  if (get_pseudo_console ())
+    {
+      UINT code_page;
+      if (lcid == 0 || lcid == (LCID) -1)
+       code_page = 20127; /* ASCII */
+      else if (!GetLocaleInfo (lcid,
+                              LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER,
+                              (char *) &code_page, sizeof (code_page)))
+       code_page = 20127; /* ASCII */
+      SetConsoleCP (code_page);
+      SetConsoleOutputCP (code_page);
+    }
 
   /* Set terminal code page from locale */
   /* This code is borrowed from mintty: charset.c */
This page took 0.03386 seconds and 5 git commands to generate.