From e561446d55d44258dd8eb5e6f0dfc4fdc6ecf66f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Jul 2019 11:13:52 +0200 Subject: [PATCH] squash??? gettext: always use UTF-8 on native Windows We need to handle `LC_ALL=C` properly, as a new t7816 test that was just introduced into `pu` would fail. Signed-off-by: Johannes Schindelin --- gettext.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gettext.c b/gettext.c index 7da80db453c4c0..35d2c1218db2e2 100644 --- a/gettext.c +++ b/gettext.c @@ -13,7 +13,23 @@ # include # include # ifdef GIT_WINDOWS_NATIVE -# define locale_charset() "UTF-8" + +static const char *locale_charset(void) +{ + const char *env = getenv("LC_ALL"), *dot; + + if (!env || !*env) + env = getenv("LC_CTYPE"); + if (!env || !*env) + env = getenv("LANG"); + + if (!env) + return "UTF-8"; + + dot = strchr(env, '.'); + return !dot ? env : dot + 1; +} + # elif defined HAVE_LIBCHARSET_H # include # else