>From 927a70e0853345315570f051fd6996cfeb7b4d96 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 23 Dec 2024 16:56:15 +0100 Subject: [PATCH 1/7] localcharset: Support the UTF-8 environment on native Windows. * lib/localcharset.c (locale_charset): Recognize also the special case of a setlocale() result that ends in ".UTF-8". --- ChangeLog | 6 ++++++ lib/localcharset.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c294898828..1ac323da3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-12-23 Bruno Haible + + localcharset: Support the UTF-8 environment on native Windows. + * lib/localcharset.c (locale_charset): Recognize also the special case + of a setlocale() result that ends in ".UTF-8". + 2024-12-23 Bruno Haible setlocale tests: Add unit test for LC_MESSAGES handling. diff --git a/lib/localcharset.c b/lib/localcharset.c index bd3367477d..755645763d 100644 --- a/lib/localcharset.c +++ b/lib/localcharset.c @@ -939,8 +939,10 @@ locale_charset (void) sprintf (buf, "CP%u", GetACP ()); } /* For a locale name such as "French_France.65001", in Windows 10, - setlocale now returns "French_France.utf8" instead. */ - if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0) + setlocale now returns "French_France.utf8" instead, or in the UTF-8 + environment (with modern system settings) "fr_FR.UTF-8". */ + if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0 + || strcmp (buf + 2, "UTF-8") == 0) codeset = "UTF-8"; else { -- 2.43.0