Merge branch 'kb/windows-force-utf8'
authorJunio C Hamano <gitster@pobox.com>
Thu, 11 Jul 2019 22:16:49 +0000 (15:16 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Jul 2019 22:16:49 +0000 (15:16 -0700)
Windows update.

* kb/windows-force-utf8:
gettext: always use UTF-8 on native Windows

gettext.c
index d4021d690c07237edefb0cf2869eb6795d227a54..3f2aca5c3b16d39375fab9b6203c67ae16209023 100644 (file)
--- a/gettext.c
+++ b/gettext.c
 #ifndef NO_GETTEXT
 #      include <locale.h>
 #      include <libintl.h>
-#      ifdef HAVE_LIBCHARSET_H
+#      ifdef GIT_WINDOWS_NATIVE
+
+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 <libcharset.h>
 #      else
 #              include <langinfo.h>