summaryrefslogtreecommitdiff
path: root/lib/c32to-impl.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-10-20 15:22:21 +0200
committerJörg Frings-Fürst <debian@jff.email>2024-10-20 15:22:21 +0200
commit1d8b9e17ea13630aec475484da09ebba0366f7c8 (patch)
tree0c801f68561bfb0930a4ade80d7ca3a7940887ab /lib/c32to-impl.h
parent84e26c587987e8484d55db4165f188b40c09e94b (diff)
parent630f99f29bd31a76d8d24da2975a045452c763ef (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'lib/c32to-impl.h')
-rw-r--r--lib/c32to-impl.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/c32to-impl.h b/lib/c32to-impl.h
index e94fa7dc..2299ab75 100644
--- a/lib/c32to-impl.h
+++ b/lib/c32to-impl.h
@@ -53,7 +53,7 @@ FUNC (wint_t wc)
else
return wc;
-#elif HAVE_WORKING_MBRTOC32 /* glibc, Android */
+#elif HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB /* glibc, Android */
/* mbrtoc32() is essentially defined by the system libc. */
# if _GL_WCHAR_T_IS_UCS4
@@ -73,11 +73,22 @@ FUNC (wint_t wc)
/* The wchar_t encoding is UTF-16.
The char32_t encoding is UCS-4. */
+# if defined _WIN32 && !defined __CYGWIN__
+ /* On native Windows, in the UTF-8 locale, towlower and towupper are
+ lacking (at least) the mappings for ISO-8859-1 characters, such as
+ 0x00C9 <-> 0x00E9. Since it is expensive to test whether the locale
+ encoding is UTF-8, ignore the system's WCHAR_FUNC altogether. */
+ if (wc != WEOF)
+ return UCS_FUNC (wc);
+ else
+ return wc;
+# else
if (wc == WEOF || wc == (wchar_t) wc)
/* wc is in the range for the tow* functions. */
return WCHAR_FUNC (wc);
else
return UCS_FUNC (wc);
+# endif
#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
/* char32_t and wchar_t are equivalent. */