* tests/test-localename-w32utf8.sh: New file.
* tests/test-localename-w32utf8.c: New file.
* modules/localename-tests (Files): Add these files and
m4/windows-rc.m4, tests/windows-utf8.rc, tests/windows-utf8.manifest.
(Depends-on): Add test-xfail.
(configure.ac): Invoke gl_WINDOWS_RC.
(Makefile.am): Arrange to compile test-localename-w32utf8 and run
test-localename-w32utf8.sh.
2024-12-23 Bruno Haible <bruno@clisp.org>
+ localename tests: Test in the UTF-8 environment on native Windows.
+ * tests/test-localename-w32utf8.sh: New file.
+ * tests/test-localename-w32utf8.c: New file.
+ * modules/localename-tests (Files): Add these files and
+ m4/windows-rc.m4, tests/windows-utf8.rc, tests/windows-utf8.manifest.
+ (Depends-on): Add test-xfail.
+ (configure.ac): Invoke gl_WINDOWS_RC.
+ (Makefile.am): Arrange to compile test-localename-w32utf8 and run
+ test-localename-w32utf8.sh.
+
localename-unsafe: Support the UTF-8 environment on native Windows.
* lib/localename-unsafe.c (gl_locale_name_from_win32_LANGID): Append a
suffix ".UTF-8" to the result if GetACP() is UTF-8.
Files:
tests/test-localename.c
+tests/test-localename-w32utf8.sh
+tests/test-localename-w32utf8.c
+tests/windows-utf8.rc
+tests/windows-utf8.manifest
tests/macros.h
m4/musl.m4
+m4/windows-rc.m4
Depends-on:
locale
unsetenv
setlocale
strdup
+test-xfail
configure.ac:
gl_CHECK_FUNCS_ANDROID([newlocale], [[#include <locale.h>]])
gl_MUSL_LIBC
+gl_WINDOWS_RC
Makefile.am:
TESTS += test-localename
check_PROGRAMS += test-localename
test_localename_LDADD = $(LDADD) $(SETLOCALE_LIB) @INTL_MACOSX_LIBS@ $(LIBTHREAD)
+if OS_IS_NATIVE_WINDOWS
+TESTS += test-localename-w32utf8.sh
+noinst_PROGRAMS += test-localename-w32utf8
+test_localename_w32utf8_LDADD = $(LDADD) test-localename-windows-utf8.res $(SETLOCALE_LIB)
+test-localename-windows-utf8.res : $(srcdir)/windows-utf8.rc
+ $(WINDRES) -i $(srcdir)/windows-utf8.rc -o test-localename-windows-utf8.res --output-format=coff
+MOSTLYCLEANFILES += test-localename-windows-utf8.res
+endif
--- /dev/null
+/* Test of gl_locale_name function and its variants
+ on native Windows in the UTF-8 environment.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+#include <config.h>
+
+#include "localename.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+#ifdef _UCRT
+ const char *name = gl_locale_name_default ();
+
+ ASSERT (name != NULL);
+
+ /* With the legacy system settings, expect "C.UTF-8", not "C", because "C" is
+ a single-byte locale.
+ With the modern system settings, expect some "ll_CC.UTF-8" name. */
+ ASSERT (strlen (name) > 6 && strcmp (name + strlen (name)- 6, ".UTF-8") == 0);
+
+ return test_exit_status;
+#else
+ fputs ("Skipping test: not using the UCRT runtime\n", stderr);
+ return 77;
+#endif
+}
--- /dev/null
+#!/bin/sh
+
+# Test the UTF-8 environment on native Windows.
+unset LC_ALL
+unset LC_CTYPE
+unset LANG
+${CHECKER} ./test-localename-w32utf8${EXEEXT}