]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: pty: Fix input charset for non-cygwin apps with disable_pcon.
authorTakashi Yano via Cygwin-patches <cygwin-patches@cygwin.com>
Wed, 9 Sep 2020 15:28:00 +0000 (00:28 +0900)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 9 Sep 2020 19:35:46 +0000 (21:35 +0200)
- If the non-cygwin apps is executed under pseudo console disabled,
  multibyte input for the apps are garbled. This patch fixes the
  issue.

winsup/cygwin/fhandler_tty.cc

index 0bfc32ea944fd48544fa02f1b49298c56a9b58e0..16d4a99f47a2ef94f18d3abacf0001bfc3495e2b 100644 (file)
@@ -295,8 +295,22 @@ fhandler_pty_master::accept_input ()
   bytes_left = eat_readahead (-1);
 
   HANDLE write_to = get_output_handle ();
+  tmp_pathbuf tp;
   if (to_be_read_from_pcon ())
-    write_to = to_slave;
+    {
+      write_to = to_slave;
+      UINT cp_to = GetConsoleCP ();
+      if (get_ttyp ()->term_code_page != cp_to)
+       {
+         static mbstate_t mbp;
+         char *mbbuf = tp.c_get ();
+         size_t nlen = NT_MAX_PATH;
+         convert_mb_str (cp_to, mbbuf, &nlen,
+                         get_ttyp ()->term_code_page, p, bytes_left, &mbp);
+         p = mbbuf;
+         bytes_left = nlen;
+       }
+    }
 
   if (!bytes_left)
     {
This page took 0.033387 seconds and 5 git commands to generate.