git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/1] gettext: always use UTF-8 on native Windows

From
Karsten Blees via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 27, 2019, 08:44 UTC
Message-ID
<ff37a2646a848e3eca8d02a001844986a3fa366b.1561625060.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.217.git.gitgitgadget@gmail.com>
From: Karsten Blees <blees@dcon.de>

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 <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 gettext.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gettext.c b/gettext.c
index d4021d690c..d8423e5c41 100644
--- a/gettext.c
+++ b/gettext.c
@@ -12,7 +12,9 @@
 #ifndef NO_GETTEXT
 #	include <locale.h>
 #	include <libintl.h>
-#	ifdef HAVE_LIBCHARSET_H
+#	ifdef GIT_WINDOWS_NATIVE
+#		define locale_charset() "UTF-8"
+#	elif defined HAVE_LIBCHARSET_H
 #		include <libcharset.h>
 #	else
 #		include <langinfo.h>
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin
Message 2 of 9 in “gettext(windows): always use UTF-8”
  1. 0/1 gettext(windows): always use UTF-8Johannes Schindelin via GitGitGadget, Jun 27, 2019
  2. 1/1 gettext: always use UTF-8 on native WindowsKarsten Blees via GitGitGadget, Jun 27, 2019
  3. Johannes SchindelinJul 3, 2019
  4. Junio C HamanoJul 3, 2019
  5. 0/1 gettext(windows): always use UTF-8Johannes Schindelin via GitGitGadget, Jul 3, 2019
  6. 1/1 gettext: always use UTF-8 on native WindowsKarsten Blees via GitGitGadget, Jul 3, 2019
  7. Ævar Arnfjörð BjarmasonJul 4, 2019
  8. Johannes SchindelinJul 8, 2019
  9. Junio C HamanoJul 8, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.