[PATCH 2/3] fhandler_pty_slave::setup_locale: fall back to UTF-8, not ASCII

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/3] fhandler_pty_slave::setup_locale: fall back to UTF-8, not ASCII

Johannes Schindelin
When we fail to determine the Console output code page to use in the
Pseudo Console, we used to fall back to ASCII.

However, a much better fall-back code page is UTF-8 because that's what
Cygwin defaults to, internally, when no encoding was specified.

Besides, `/etc/profile.d/lang.sh` essentially sets `LANG=$(locale -uU)`
(where the `-U` says that `.UTF-8` should be appended). Meaning: we
_really_ want to use the UTF-8 code page.

Signed-off-by: Johannes Schindelin <[hidden email]>
---
 winsup/cygwin/fhandler_tty.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index b3458595a..06789a500 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2864,11 +2864,11 @@ fhandler_pty_slave::setup_locale (void)
     {
       UINT code_page;
       if (lcid == 0 || lcid == (LCID) -1)
- code_page = 20127; /* ASCII */
+ code_page = CP_UTF8; /* Cygwin prefers UTF-8 */
       else if (!GetLocaleInfo (lcid,
        LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER,
        (char *) &code_page, sizeof (code_page)))
- code_page = 20127; /* ASCII */
+ code_page = CP_UTF8; /* Cygwin prefers UTF-8 */
       SetConsoleCP (code_page);
       SetConsoleOutputCP (code_page);
     }
--
2.27.0