From 7873f7bac648057f287ed76b112d0bf729286f31 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 23 Dec 2024 16:56:15 +0100 Subject: [PATCH] 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 bed8eb1cd3..adc4341a13 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: Handle LC_MESSAGES correctly on native Windows. diff --git a/lib/localcharset.c b/lib/localcharset.c index 93c4baa471..0245ea3576 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.39.5