I wrote:
>  7.32.3.2
>   towctrans           --             rarely used
>   wctrans             --             rarely used

It's not hard to implement replacements for these two functions either.
So that we get this correspondence:

  wchar_t             char32_t
  -------             --------

  towctrans           c32_apply_mapping
  wctrans             c32_get_mapping


2023-07-13  Bruno Haible  <br...@clisp.org>

        doc: Mention c32_get_mapping, c32_apply_mapping.
        * doc/posix-functions/wctrans.texi: Mention c32_get_mapping.
        * doc/posix-functions/towctrans.texi: Mention c32_apply_mapping.
        * doc/strings.texi (Comparison of character APIs): Mention both.

        c32_apply_mapping: Add tests.
        * tests/test-c32_apply_mapping.c: New file.
        * modules/c32_apply_mapping-tests: New file.

        c32_apply_mapping: New module.
        * lib/uchar.in.h (c32_apply_mapping): New declaration.
        * lib/c32_apply_mapping.c: New file.
        * m4/uchar_h.m4 (gl_UCHAR_H_REQUIRE_DEFAULTS): Initialize
        GNULIB_C32_APPLY_MAPPING.
        * modules/uchar (Makefile.am): Substitute GNULIB_C32_APPLY_MAPPING.
        * modules/c32_apply_mapping: New file.

        c32_get_mapping: Add tests.
        * tests/test-c32_get_mapping.c: New file.
        * modules/c32_get_mapping-tests: New file.

        c32_get_mapping: New module.
        * lib/uchar.in.h (c32_mapping_t): New type.
        (c32_get_mapping): New declaration.
        * lib/c32_get_mapping.c: New file, based on lib/wctrans-impl.h.
        * m4/uchar_h.m4 (gl_UCHAR_H_REQUIRE_DEFAULTS): Initialize
        GNULIB_C32_GET_MAPPING.
        * modules/uchar (Makefile.am): Substitute GNULIB_C32_GET_MAPPING.
        * modules/c32_get_mapping: New file.

        towctrans: Relax license.
        * modules/towctrans (License): Change to LGPLv2+.
        * lib/towctrans.c: Update license notice.
        * lib/towctrans-impl.h: Likewise.

        wctrans: Relax license.
        * modules/wctrans (License): Change to LGPLv2+.
        * lib/wctrans.c: Update license notice.
        * lib/wctrans-impl.h: Likewise.

>From a585405330c8fcb020f6f0b4f9caa8c972e89174 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 13 Jul 2023 10:58:56 +0200
Subject: [PATCH 1/7] wctrans: Relax license.

* modules/wctrans (License): Change to LGPLv2+.
* lib/wctrans.c: Update license notice.
* lib/wctrans-impl.h: Likewise.
---
 ChangeLog          | 7 +++++++
 lib/wctrans-impl.h | 2 +-
 lib/wctrans.c      | 2 +-
 modules/wctrans    | 2 +-
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 764fc15ea1..af2b1b46a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-07-13  Bruno Haible  <br...@clisp.org>
+
+	wctrans: Relax license.
+	* modules/wctrans (License): Change to LGPLv2+.
+	* lib/wctrans.c: Update license notice.
+	* lib/wctrans-impl.h: Likewise.
+
 2023-07-12  Bruno Haible  <br...@clisp.org>
 
 	doc: Mention c32_get_type_test, c32_apply_type_test.
diff --git a/lib/wctrans-impl.h b/lib/wctrans-impl.h
index 9bd7a38af9..be0ae7eb37 100644
--- a/lib/wctrans-impl.h
+++ b/lib/wctrans-impl.h
@@ -4,7 +4,7 @@
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation, either version 3 of the
+   published by the Free Software Foundation; either version 2.1 of the
    License, or (at your option) any later version.
 
    This file is distributed in the hope that it will be useful,
diff --git a/lib/wctrans.c b/lib/wctrans.c
index e1db929362..2084a2d580 100644
--- a/lib/wctrans.c
+++ b/lib/wctrans.c
@@ -4,7 +4,7 @@
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation, either version 3 of the
+   published by the Free Software Foundation; either version 2.1 of the
    License, or (at your option) any later version.
 
    This file is distributed in the hope that it will be useful,
diff --git a/modules/wctrans b/modules/wctrans
index 5b7e57ae2b..99e95013b7 100644
--- a/modules/wctrans
+++ b/modules/wctrans
@@ -23,7 +23,7 @@ Include:
 <wctype.h>
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 all
-- 
2.34.1

>From fdcb6772f86c7c775aa60c222351d268db0d067c Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 13 Jul 2023 11:01:22 +0200
Subject: [PATCH 2/7] towctrans: Relax license.

* modules/towctrans (License): Change to LGPLv2+.
* lib/towctrans.c: Update license notice.
* lib/towctrans-impl.h: Likewise.
---
 ChangeLog            | 5 +++++
 lib/towctrans-impl.h | 2 +-
 lib/towctrans.c      | 2 +-
 modules/towctrans    | 2 +-
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index af2b1b46a9..3f8e0c7744 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2023-07-13  Bruno Haible  <br...@clisp.org>
 
+	towctrans: Relax license.
+	* modules/towctrans (License): Change to LGPLv2+.
+	* lib/towctrans.c: Update license notice.
+	* lib/towctrans-impl.h: Likewise.
+
 	wctrans: Relax license.
 	* modules/wctrans (License): Change to LGPLv2+.
 	* lib/wctrans.c: Update license notice.
diff --git a/lib/towctrans-impl.h b/lib/towctrans-impl.h
index e512d30694..9c8fd8b8c3 100644
--- a/lib/towctrans-impl.h
+++ b/lib/towctrans-impl.h
@@ -4,7 +4,7 @@
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation, either version 3 of the
+   published by the Free Software Foundation; either version 2.1 of the
    License, or (at your option) any later version.
 
    This file is distributed in the hope that it will be useful,
diff --git a/lib/towctrans.c b/lib/towctrans.c
index 4328d9a490..c1c4844a2c 100644
--- a/lib/towctrans.c
+++ b/lib/towctrans.c
@@ -4,7 +4,7 @@
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation, either version 3 of the
+   published by the Free Software Foundation; either version 2.1 of the
    License, or (at your option) any later version.
 
    This file is distributed in the hope that it will be useful,
diff --git a/modules/towctrans b/modules/towctrans
index 7a58232303..1d61efe8ee 100644
--- a/modules/towctrans
+++ b/modules/towctrans
@@ -23,7 +23,7 @@ Include:
 <wctype.h>
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 all
-- 
2.34.1

>From 07edc55417b0677ffd2d0ad50e2b64d43cafb9a9 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 13 Jul 2023 11:15:04 +0200
Subject: [PATCH 3/7] c32_get_mapping: New module.

* lib/uchar.in.h (c32_mapping_t): New type.
(c32_get_mapping): New declaration.
* lib/c32_get_mapping.c: New file, based on lib/wctrans-impl.h.
* m4/uchar_h.m4 (gl_UCHAR_H_REQUIRE_DEFAULTS): Initialize
GNULIB_C32_GET_MAPPING.
* modules/uchar (Makefile.am): Substitute GNULIB_C32_GET_MAPPING.
* modules/c32_get_mapping: New file.
---
 ChangeLog               |  9 +++++++
 lib/c32_get_mapping.c   | 54 +++++++++++++++++++++++++++++++++++++++++
 lib/uchar.in.h          | 35 ++++++++++++++++++++++++++
 m4/uchar_h.m4           |  3 ++-
 modules/c32_get_mapping | 31 +++++++++++++++++++++++
 modules/uchar           |  1 +
 6 files changed, 132 insertions(+), 1 deletion(-)
 create mode 100644 lib/c32_get_mapping.c
 create mode 100644 modules/c32_get_mapping

diff --git a/ChangeLog b/ChangeLog
index 3f8e0c7744..6356827f51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2023-07-13  Bruno Haible  <br...@clisp.org>
 
+	c32_get_mapping: New module.
+	* lib/uchar.in.h (c32_mapping_t): New type.
+	(c32_get_mapping): New declaration.
+	* lib/c32_get_mapping.c: New file, based on lib/wctrans-impl.h.
+	* m4/uchar_h.m4 (gl_UCHAR_H_REQUIRE_DEFAULTS): Initialize
+	GNULIB_C32_GET_MAPPING.
+	* modules/uchar (Makefile.am): Substitute GNULIB_C32_GET_MAPPING.
+	* modules/c32_get_mapping: New file.
+
 	towctrans: Relax license.
 	* modules/towctrans (License): Change to LGPLv2+.
 	* lib/towctrans.c: Update license notice.
diff --git a/lib/c32_get_mapping.c b/lib/c32_get_mapping.c
new file mode 100644
index 0000000000..691e37a295
--- /dev/null
+++ b/lib/c32_get_mapping.c
@@ -0,0 +1,54 @@
+/* Get descriptor for a 32-bit wide character case conversion.
+   Copyright (C) 2011-2023 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   This file 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 Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <br...@clisp.org>, 2023.  */
+
+#include <config.h>
+
+#define IN_C32_GET_MAPPING
+/* Specification.  */
+#include <uchar.h>
+
+#include <string.h>
+#include <wctype.h>
+
+#if _GL_WCHAR_T_IS_UCS4
+_GL_EXTERN_INLINE
+#endif
+c32_mapping_t
+c32_get_mapping (const char *name)
+{
+#if _GL_WCHAR_T_IS_UCS4
+  return wctrans (name);
+#else
+  if (name[0] == 't'
+      && name[1] == 'o')
+    switch (name[2])
+      {
+      case 'l':
+        if (strcmp (name + 3, "ower") == 0)
+          return c32tolower;
+        break;
+      case 'u':
+        if (strcmp (name + 3, "pper") == 0)
+          return c32toupper;
+        break;
+      default:
+        break;
+      }
+  return (c32_mapping_t) 0;
+#endif
+}
diff --git a/lib/uchar.in.h b/lib/uchar.in.h
index edb6a751fd..28a5bd6244 100644
--- a/lib/uchar.in.h
+++ b/lib/uchar.in.h
@@ -729,6 +729,41 @@ _GL_CXXALIASWARN (c32_apply_type_test);
 #endif
 
 
+#if @GNULIB_C32_GET_MAPPING@
+/* A scalar type.  Instances of this type, other than (c32_mapping_t) 0,
+   represent a character mapping.  It can be applied to 32-bit wide characters.
+   It is the counterpart of type 'wctrans_t' for wide characters.
+   To apply a certain mapping to a given character, use the function
+   'c32_apply_mapping'.  */
+# if _GL_WCHAR_T_IS_UCS4
+typedef wctrans_t c32_mapping_t;
+# else
+typedef wint_t (*c32_mapping_t) (wint_t wc);
+# endif
+#endif
+
+/* Return a character mapping with the given name, or (c32_mapping_t) 0
+   if the designated mapping does not exist.
+   This function is the counterpart of function 'wctrans' for wide characters.
+ */
+#if @GNULIB_C32_GET_MAPPING@
+# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_MAPPING
+_GL_BEGIN_C_LINKAGE
+_GL_INLINE _GL_ARG_NONNULL ((1)) c32_mapping_t
+c32_get_mapping (const char *name)
+{
+  return wctrans (name);
+}
+_GL_END_C_LINKAGE
+# else
+_GL_FUNCDECL_SYS (c32_get_mapping, c32_mapping_t, (const char *name)
+                                                  _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (c32_get_mapping, c32_mapping_t, (const char *name));
+_GL_CXXALIASWARN (c32_get_mapping);
+#endif
+
+
 _GL_INLINE_HEADER_END
 
 #endif /* _@GUARD_PREFIX@_UCHAR_H */
diff --git a/m4/uchar_h.m4 b/m4/uchar_h.m4
index 2bc52480d1..16cce8a468 100644
--- a/m4/uchar_h.m4
+++ b/m4/uchar_h.m4
@@ -1,4 +1,4 @@
-# uchar_h.m4 serial 29
+# uchar_h.m4 serial 30
 dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -224,6 +224,7 @@ AC_DEFUN([gl_UCHAR_H_REQUIRE_DEFAULTS]
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32SWIDTH])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32TOB])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_APPLY_TYPE_TEST])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_GET_MAPPING])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_GET_TYPE_TEST])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOC16])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOC32])
diff --git a/modules/c32_get_mapping b/modules/c32_get_mapping
new file mode 100644
index 0000000000..140a92e99b
--- /dev/null
+++ b/modules/c32_get_mapping
@@ -0,0 +1,31 @@
+Description:
+c32_get_mapping() function: get descriptor for a 32-bit wide character
+case conversion.
+
+Files:
+lib/c32_get_mapping.c
+
+Depends-on:
+uchar
+wctrans
+c32tolower
+c32toupper
+
+configure.ac:
+gl_UCHAR_MODULE_INDICATOR([c32_get_mapping])
+
+Makefile.am:
+lib_SOURCES += c32_get_mapping.c
+
+Include:
+<uchar.h>
+
+Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
diff --git a/modules/uchar b/modules/uchar
index 1f42c6a08c..4e4d0ecd69 100644
--- a/modules/uchar
+++ b/modules/uchar
@@ -61,6 +61,7 @@ uchar.h: uchar.in.h $(top_builddir)/config.status $(CXXDEFS_H)
 	      -e 's/@''GNULIB_C32SWIDTH''@/$(GNULIB_C32SWIDTH)/g' \
 	      -e 's/@''GNULIB_C32TOB''@/$(GNULIB_C32TOB)/g' \
 	      -e 's/@''GNULIB_C32_APPLY_TYPE_TEST''@/$(GNULIB_C32_APPLY_TYPE_TEST)/g' \
+	      -e 's/@''GNULIB_C32_GET_MAPPING''@/$(GNULIB_C32_GET_MAPPING)/g' \
 	      -e 's/@''GNULIB_C32_GET_TYPE_TEST''@/$(GNULIB_C32_GET_TYPE_TEST)/g' \
 	      -e 's/@''GNULIB_MBRTOC16''@/$(GNULIB_MBRTOC16)/g' \
 	      -e 's/@''GNULIB_MBRTOC32''@/$(GNULIB_MBRTOC32)/g' \
-- 
2.34.1

>From fb75d457860598191022f8d0bf0802fd87a0785c Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 13 Jul 2023 11:19:04 +0200
Subject: [PATCH 4/7] c32_get_mapping: Add tests.

* tests/test-c32_get_mapping.c: New file.
* modules/c32_get_mapping-tests: New file.
---
 ChangeLog                     |  4 ++++
 modules/c32_get_mapping-tests | 13 +++++++++++
 tests/test-c32_get_mapping.c  | 43 +++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)
 create mode 100644 modules/c32_get_mapping-tests
 create mode 100644 tests/test-c32_get_mapping.c

diff --git a/ChangeLog b/ChangeLog
index 6356827f51..ac57f26980 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2023-07-13  Bruno Haible  <br...@clisp.org>
 
+	c32_get_mapping: Add tests.
+	* tests/test-c32_get_mapping.c: New file.
+	* modules/c32_get_mapping-tests: New file.
+
 	c32_get_mapping: New module.
 	* lib/uchar.in.h (c32_mapping_t): New type.
 	(c32_get_mapping): New declaration.
diff --git a/modules/c32_get_mapping-tests b/modules/c32_get_mapping-tests
new file mode 100644
index 0000000000..be69d1e2a0
--- /dev/null
+++ b/modules/c32_get_mapping-tests
@@ -0,0 +1,13 @@
+Files:
+tests/test-c32_get_mapping.c
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-c32_get_mapping
+check_PROGRAMS += test-c32_get_mapping
+test_c32_get_mapping_LDADD = $(LDADD) $(LIBUNISTRING) $(LIBC32CONV)
diff --git a/tests/test-c32_get_mapping.c b/tests/test-c32_get_mapping.c
new file mode 100644
index 0000000000..4723fbe5bd
--- /dev/null
+++ b/tests/test-c32_get_mapping.c
@@ -0,0 +1,43 @@
+/* Test of getting descriptor for a 32-bit wide character mapping.
+   Copyright (C) 2023 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 <br...@clisp.org>, 2023.  */
+
+#include <config.h>
+
+#include <uchar.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (c32_get_mapping, c32_mapping_t, (const char *));
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  c32_mapping_t desc;
+
+  desc = c32_get_mapping ("any");
+  ASSERT (desc == (c32_mapping_t) 0);
+
+  desc = c32_get_mapping ("tolower");
+  ASSERT (desc != (c32_mapping_t) 0);
+
+  desc = c32_get_mapping ("toupper");
+  ASSERT (desc != (c32_mapping_t) 0);
+
+  return 0;
+}
-- 
2.34.1

>From 64be6ac85c8dadf67a7d90880e648fb6e053b75a Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 13 Jul 2023 11:30:54 +0200
Subject: [PATCH 5/7] c32_apply_mapping: New module.

* lib/uchar.in.h (c32_apply_mapping): New declaration.
* lib/c32_apply_mapping.c: New file.
* m4/uchar_h.m4 (gl_UCHAR_H_REQUIRE_DEFAULTS): Initialize
GNULIB_C32_APPLY_MAPPING.
* modules/uchar (Makefile.am): Substitute GNULIB_C32_APPLY_MAPPING.
* modules/c32_apply_mapping: New file.
---
 ChangeLog                 |  8 ++++++++
 lib/c32_apply_mapping.c   | 39 +++++++++++++++++++++++++++++++++++++++
 lib/uchar.in.h            | 26 +++++++++++++++++++++++++-
 m4/uchar_h.m4             |  3 ++-
 modules/c32_apply_mapping | 25 +++++++++++++++++++++++++
 modules/uchar             |  1 +
 6 files changed, 100 insertions(+), 2 deletions(-)
 create mode 100644 lib/c32_apply_mapping.c
 create mode 100644 modules/c32_apply_mapping

diff --git a/ChangeLog b/ChangeLog
index ac57f26980..bf5caac9da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2023-07-13  Bruno Haible  <br...@clisp.org>
 
+	c32_apply_mapping: New module.
+	* lib/uchar.in.h (c32_apply_mapping): New declaration.
+	* lib/c32_apply_mapping.c: New file.
+	* m4/uchar_h.m4 (gl_UCHAR_H_REQUIRE_DEFAULTS): Initialize
+	GNULIB_C32_APPLY_MAPPING.
+	* modules/uchar (Makefile.am): Substitute GNULIB_C32_APPLY_MAPPING.
+	* modules/c32_apply_mapping: New file.
+
 	c32_get_mapping: Add tests.
 	* tests/test-c32_get_mapping.c: New file.
 	* modules/c32_get_mapping-tests: New file.
diff --git a/lib/c32_apply_mapping.c b/lib/c32_apply_mapping.c
new file mode 100644
index 0000000000..3c8be33fb1
--- /dev/null
+++ b/lib/c32_apply_mapping.c
@@ -0,0 +1,39 @@
+/* Apply a 32-bit wide character case conversion.
+   Copyright (C) 2011-2023 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   This file 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 Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <br...@clisp.org>, 2023.  */
+
+#include <config.h>
+
+#define IN_C32_APPLY_MAPPING
+/* Specification.  */
+#include <uchar.h>
+
+#include <string.h>
+#include <wctype.h>
+
+#if _GL_WCHAR_T_IS_UCS4
+_GL_EXTERN_INLINE
+#endif
+wint_t
+c32_apply_mapping (wint_t wc, c32_mapping_t mapping)
+{
+#if _GL_WCHAR_T_IS_UCS4
+  return towctrans (wc, mapping);
+#else
+  return mapping (wc);
+#endif
+}
diff --git a/lib/uchar.in.h b/lib/uchar.in.h
index 28a5bd6244..eed6db3c54 100644
--- a/lib/uchar.in.h
+++ b/lib/uchar.in.h
@@ -729,7 +729,7 @@ _GL_CXXALIASWARN (c32_apply_type_test);
 #endif
 
 
-#if @GNULIB_C32_GET_MAPPING@
+#if @GNULIB_C32_GET_MAPPING@ || @GNULIB_C32_APPLY_MAPPING@
 /* A scalar type.  Instances of this type, other than (c32_mapping_t) 0,
    represent a character mapping.  It can be applied to 32-bit wide characters.
    It is the counterpart of type 'wctrans_t' for wide characters.
@@ -763,6 +763,30 @@ _GL_CXXALIAS_SYS (c32_get_mapping, c32_mapping_t, (const char *name));
 _GL_CXXALIASWARN (c32_get_mapping);
 #endif
 
+/* Apply the specified character mapping to a given 32-bit wide character.
+   Return the result of this mapping.  Return the WC argument unchanged if it is
+   WEOF.
+   This function is the counterpart of function 'towctrans' for wide characters.
+ */
+#if @GNULIB_C32_APPLY_MAPPING@
+# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_APPLY_MAPPING
+_GL_BEGIN_C_LINKAGE
+_GL_INLINE _GL_ARG_NONNULL ((2)) wint_t
+c32_apply_mapping (wint_t wc, c32_mapping_t mapping)
+{
+  return towctrans (wc, mapping);
+}
+_GL_END_C_LINKAGE
+# else
+_GL_FUNCDECL_SYS (c32_apply_mapping, wint_t,
+                  (wint_t wc, c32_mapping_t mapping)
+                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (c32_apply_mapping, wint_t,
+                  (wint_t wc, c32_mapping_t mapping));
+_GL_CXXALIASWARN (c32_apply_mapping);
+#endif
+
 
 _GL_INLINE_HEADER_END
 
diff --git a/m4/uchar_h.m4 b/m4/uchar_h.m4
index 16cce8a468..299075f572 100644
--- a/m4/uchar_h.m4
+++ b/m4/uchar_h.m4
@@ -1,4 +1,4 @@
-# uchar_h.m4 serial 30
+# uchar_h.m4 serial 31
 dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -223,6 +223,7 @@ AC_DEFUN([gl_UCHAR_H_REQUIRE_DEFAULTS]
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32STOMBS])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32SWIDTH])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32TOB])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_APPLY_MAPPING])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_APPLY_TYPE_TEST])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_GET_MAPPING])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_GET_TYPE_TEST])
diff --git a/modules/c32_apply_mapping b/modules/c32_apply_mapping
new file mode 100644
index 0000000000..49308259d0
--- /dev/null
+++ b/modules/c32_apply_mapping
@@ -0,0 +1,25 @@
+Description:
+c32_apply_mapping() function: convert a 32-bit wide character using a
+case mapping.
+
+Files:
+lib/c32_apply_mapping.c
+
+Depends-on:
+uchar
+towctrans
+
+configure.ac:
+gl_UCHAR_MODULE_INDICATOR([c32_apply_mapping])
+
+Makefile.am:
+lib_SOURCES += c32_apply_mapping.c
+
+Include:
+<uchar.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
diff --git a/modules/uchar b/modules/uchar
index 4e4d0ecd69..69ce596869 100644
--- a/modules/uchar
+++ b/modules/uchar
@@ -60,6 +60,7 @@ uchar.h: uchar.in.h $(top_builddir)/config.status $(CXXDEFS_H)
 	      -e 's/@''GNULIB_C32STOMBS''@/$(GNULIB_C32STOMBS)/g' \
 	      -e 's/@''GNULIB_C32SWIDTH''@/$(GNULIB_C32SWIDTH)/g' \
 	      -e 's/@''GNULIB_C32TOB''@/$(GNULIB_C32TOB)/g' \
+	      -e 's/@''GNULIB_C32_APPLY_MAPPING''@/$(GNULIB_C32_APPLY_MAPPING)/g' \
 	      -e 's/@''GNULIB_C32_APPLY_TYPE_TEST''@/$(GNULIB_C32_APPLY_TYPE_TEST)/g' \
 	      -e 's/@''GNULIB_C32_GET_MAPPING''@/$(GNULIB_C32_GET_MAPPING)/g' \
 	      -e 's/@''GNULIB_C32_GET_TYPE_TEST''@/$(GNULIB_C32_GET_TYPE_TEST)/g' \
-- 
2.34.1

>From ed4711658b5fb4ea3d715be7c5ae4517c8ef5267 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 13 Jul 2023 13:37:01 +0200
Subject: [PATCH 6/7] c32_apply_mapping: Add tests.

* tests/test-c32_apply_mapping.c: New file.
* modules/c32_apply_mapping-tests: New file.
---
 ChangeLog                       |  4 +++
 modules/c32_apply_mapping-tests | 14 ++++++++
 tests/test-c32_apply_mapping.c  | 60 +++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 modules/c32_apply_mapping-tests
 create mode 100644 tests/test-c32_apply_mapping.c

diff --git a/ChangeLog b/ChangeLog
index bf5caac9da..2e8c72eeda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2023-07-13  Bruno Haible  <br...@clisp.org>
 
+	c32_apply_mapping: Add tests.
+	* tests/test-c32_apply_mapping.c: New file.
+	* modules/c32_apply_mapping-tests: New file.
+
 	c32_apply_mapping: New module.
 	* lib/uchar.in.h (c32_apply_mapping): New declaration.
 	* lib/c32_apply_mapping.c: New file.
diff --git a/modules/c32_apply_mapping-tests b/modules/c32_apply_mapping-tests
new file mode 100644
index 0000000000..5bd6f7f698
--- /dev/null
+++ b/modules/c32_apply_mapping-tests
@@ -0,0 +1,14 @@
+Files:
+tests/test-c32_apply_mapping.c
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+c32_get_mapping
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-c32_apply_mapping
+check_PROGRAMS += test-c32_apply_mapping
+test_c32_apply_mapping_LDADD = $(LDADD) $(LIBUNISTRING) $(LIBC32CONV)
diff --git a/tests/test-c32_apply_mapping.c b/tests/test-c32_apply_mapping.c
new file mode 100644
index 0000000000..4e1a385da5
--- /dev/null
+++ b/tests/test-c32_apply_mapping.c
@@ -0,0 +1,60 @@
+/* Test of 32-bit wide character mappings.
+   Copyright (C) 2023 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 <br...@clisp.org>, 2023.  */
+
+#include <config.h>
+
+#include <uchar.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (c32_apply_mapping, wint_t, (wint_t, c32_mapping_t));
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  c32_mapping_t desc;
+
+  desc = c32_get_mapping ("any");
+  ASSERT (desc == (c32_mapping_t) 0);
+
+  desc = c32_get_mapping ("tolower");
+  ASSERT (desc != (c32_mapping_t) 0);
+  ASSERT (c32_apply_mapping ((char32_t) 'a', desc) == 'a');
+  ASSERT (c32_apply_mapping ((char32_t) 'z', desc) == 'z');
+  ASSERT (c32_apply_mapping ((char32_t) 'A', desc) == 'a');
+  ASSERT (c32_apply_mapping ((char32_t) 'Z', desc) == 'z');
+  ASSERT (c32_apply_mapping ((char32_t) '1', desc) == '1');
+  ASSERT (c32_apply_mapping ((char32_t) '_', desc) == '_');
+  ASSERT (c32_apply_mapping ((char32_t) '_', desc) == '_');
+  ASSERT (c32_apply_mapping ((char32_t) 0, desc) == 0);
+  ASSERT (c32_apply_mapping (WEOF, desc) == WEOF);
+
+  desc = c32_get_mapping ("toupper");
+  ASSERT (desc != (c32_mapping_t) 0);
+  ASSERT (c32_apply_mapping ((char32_t) 'A', desc) == 'A');
+  ASSERT (c32_apply_mapping ((char32_t) 'Z', desc) == 'Z');
+  ASSERT (c32_apply_mapping ((char32_t) 'a', desc) == 'A');
+  ASSERT (c32_apply_mapping ((char32_t) 'z', desc) == 'Z');
+  ASSERT (c32_apply_mapping ((char32_t) '1', desc) == '1');
+  ASSERT (c32_apply_mapping ((char32_t) '_', desc) == '_');
+  ASSERT (c32_apply_mapping ((char32_t) 0, desc) == 0);
+  ASSERT (c32_apply_mapping (WEOF, desc) == WEOF);
+
+  return 0;
+}
-- 
2.34.1

>From c9368f9c8d7c521dfacb60601c852c3423b7d103 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 13 Jul 2023 13:42:08 +0200
Subject: [PATCH 7/7] doc: Mention c32_get_mapping, c32_apply_mapping.

* doc/posix-functions/wctrans.texi: Mention c32_get_mapping.
* doc/posix-functions/towctrans.texi: Mention c32_apply_mapping.
* doc/strings.texi (Comparison of character APIs): Mention both.
---
 ChangeLog                          | 5 +++++
 doc/posix-functions/towctrans.texi | 3 +++
 doc/posix-functions/wctrans.texi   | 3 +++
 doc/strings.texi                   | 8 +++++++-
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 2e8c72eeda..76031ff912 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2023-07-13  Bruno Haible  <br...@clisp.org>
 
+	doc: Mention c32_get_mapping, c32_apply_mapping.
+	* doc/posix-functions/wctrans.texi: Mention c32_get_mapping.
+	* doc/posix-functions/towctrans.texi: Mention c32_apply_mapping.
+	* doc/strings.texi (Comparison of character APIs): Mention both.
+
 	c32_apply_mapping: Add tests.
 	* tests/test-c32_apply_mapping.c: New file.
 	* modules/c32_apply_mapping-tests: New file.
diff --git a/doc/posix-functions/towctrans.texi b/doc/posix-functions/towctrans.texi
index 838701fb9c..6cbf58e6c6 100644
--- a/doc/posix-functions/towctrans.texi
+++ b/doc/posix-functions/towctrans.texi
@@ -18,4 +18,7 @@
 @item
 On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
+However, the Gnulib function @code{c32_apply_mapping}, provided by Gnulib
+module @code{c32_apply_mapping}, operates on 32-bit wide characters and
+therefore does not have this limitation.
 @end itemize
diff --git a/doc/posix-functions/wctrans.texi b/doc/posix-functions/wctrans.texi
index 2fcc2df44a..b48ac9658c 100644
--- a/doc/posix-functions/wctrans.texi
+++ b/doc/posix-functions/wctrans.texi
@@ -18,4 +18,7 @@
 @item
 On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
+However, the Gnulib function @code{c32_get_mapping}, provided by Gnulib module
+@code{c32_get_mapping}, operates on 32-bit wide characters and therefore does
+not have this limitation.
 @end itemize
diff --git a/doc/strings.texi b/doc/strings.texi
index 9ea9c8a5b8..32165ac403 100644
--- a/doc/strings.texi
+++ b/doc/strings.texi
@@ -858,8 +858,14 @@
 
 @item --
 @tab --
-@tab @code{towctrans}
+@tab @code{wctrans}
+@tab @code{c32_get_mapping}
 @tab --
+
+@item --
+@tab --
+@tab @code{towctrans}
+@tab @code{c32_apply_mapping}
 @tab --
 
 @item --
-- 
2.34.1

Reply via email to