]> Savannah Git Hosting - gnulib.git/commitdiff
localcharset: Support the UTF-8 environment on native Windows.
authorBruno Haible <bruno@clisp.org>
Mon, 23 Dec 2024 15:56:15 +0000 (16:56 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 25 Dec 2024 14:32:43 +0000 (15:32 +0100)
* lib/localcharset.c (locale_charset): Recognize also the special case
of a setlocale() result that ends in ".UTF-8".

ChangeLog
lib/localcharset.c

index bed8eb1cd3c740bf658eda220d9053759d1625f3..adc4341a1383385b2d927e142dca13da477e3825 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-23  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        setlocale: Handle LC_MESSAGES correctly on native Windows.
index 93c4baa471485f02d4ebab1a04890c485271bcf3..0245ea3576ba39aae196d6b32318e787cf2fcdd8 100644 (file)
@@ -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
     {