Skip to content

Commit adb89a2

Browse files
kbleesGit for Windows Build Agent
authored andcommitted
gettext: always use UTF-8 on native Windows
Git on native Windows exclusively uses UTF-8 for console output (both with mintty and native console windows). Gettext uses setlocale() to determine the output encoding for translated text, however, MSVCRT's setlocale() doesn't support UTF-8. As a result, translated text is encoded in system encoding (GetAPC()), and non-ASCII chars are mangled in console output. Use gettext's bind_textdomain_codeset() to force the encoding to UTF-8 on native Windows. In this developers' setup, HAVE_LIBCHARSET_H is apparently defined, but we *really* want to override the locale_charset() here. Signed-off-by: Karsten Blees <[email protected]>
1 parent 45a2e89 commit adb89a2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gettext.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#ifndef NO_GETTEXT
1111
# include <locale.h>
1212
# include <libintl.h>
13-
# ifdef HAVE_LIBCHARSET_H
13+
# ifdef GIT_WINDOWS_NATIVE
14+
# define locale_charset() "UTF-8"
15+
# elif defined HAVE_LIBCHARSET_H
1416
# include <libcharset.h>
1517
# else
1618
# include <langinfo.h>

0 commit comments

Comments
 (0)