1 /* <uchar.h> substitute - 16-bit and 32-bit wide character types.
2 Copyright (C) 2019-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2019. */
20 * ISO C 23 <uchar.h> for platforms that lack it.
23 #ifndef _@GUARD_PREFIX@_UCHAR_H
26 @PRAGMA_SYSTEM_HEADER@
30 /* The include_next requires a split double-inclusion guard. */
32 # if defined __HAIKU__
33 /* Work around <https://dev.haiku-os.org/ticket/17040>. */
36 /* On AIX 7.2 with xlclang++, /usr/include/uchar.h produces compilation errors
37 because it contains typedef definitions of char16_t and char32_t, however
38 char16_t and char32_t are keywords in this situation. To work around it,
39 define char16_t and char32_t as macros. */
40 # if defined __cplusplus && defined _AIX && defined __ibmxl__ && defined __clang__
41 # define char16_t gl_char16_t
42 # define char32_t gl_char32_t
44 # @INCLUDE_NEXT@ @NEXT_UCHAR_H@
47 #ifndef _@GUARD_PREFIX@_UCHAR_H
48 #define _@GUARD_PREFIX@_UCHAR_H
50 /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_BEGIN_C_LINKAGE,
51 _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
52 #if !_GL_CONFIG_H_INCLUDED
53 #error "Please include config.h first."
56 /* Get uint_least16_t, uint_least32_t. */
59 /* Get mbstate_t, size_t. */
62 /* For the inline functions. */
66 /* The __attribute__ feature is available in gcc versions 2.5 and later.
67 The attribute __pure__ was added in gcc 2.96. */
68 #ifndef _GL_ATTRIBUTE_PURE
69 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
70 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
72 # define _GL_ATTRIBUTE_PURE /* empty */
76 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
78 /* The definition of _GL_ARG_NONNULL is copied here. */
80 /* The definition of _GL_WARN_ON_USE is copied here. */
83 _GL_INLINE_HEADER_BEGIN
86 #if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_CHAR8_TYPE@))
88 /* An 8-bit variant of wchar_t.
89 Note: This type is only mandated by ISO C 23 or newer, and it does
90 denote UTF-8 units. */
91 typedef unsigned char char8_t
;
93 #elif @GNULIBHEADERS_OVERRIDE_CHAR8_T@
95 typedef unsigned char gl_char8_t
;
96 # define char8_t gl_char8_t
100 #if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_UCHAR_TYPES@))
102 /* A 16-bit variant of wchar_t.
103 Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
104 and newer, it denotes UTF-16 units; in older versions of ISO C it did
105 so only on platforms on which __STDC_UTF_16__ was defined. */
106 typedef uint_least16_t char16_t
;
108 #elif @GNULIBHEADERS_OVERRIDE_CHAR16_T@
110 typedef uint_least16_t gl_char16_t
;
111 # define char16_t gl_char16_t
115 #if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_UCHAR_TYPES@))
117 /* A 32-bit variant of wchar_t.
118 Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
119 and newer, it denotes UTF-32 code points; in older versions of ISO C
120 it did so only on platforms on which __STDC_UTF_32__ was defined.
121 In gnulib, we guarantee that it denotes UTF-32 code points if and
122 only if the module 'uchar-c23' is in use. */
123 typedef uint_least32_t char32_t
;
125 #elif @GNULIBHEADERS_OVERRIDE_CHAR32_T@
127 typedef uint_least32_t gl_char32_t
;
128 # define char32_t gl_char32_t
132 /* Define if a 'char32_t' can hold more characters than a 'wchar_t'. */
133 #if @SMALL_WCHAR_T@ /* 32-bit AIX, Cygwin, native Windows */
134 # define _GL_SMALL_WCHAR_T 1
137 /* Define if 'wchar_t', like 'char32_t',
138 - is a 32-bit type, and
139 - represents Unicode code points.
140 For this test, we can use __STDC_ISO_10646__ (defined by glibc, musl libc,
141 Cygwin) but need to consider _GL_SMALL_WCHAR_T, so as to exclude Cygwin.
142 We cannot use __STDC_UTF_16__ or __STDC_UTF_32__
143 - because these macros provide info about char16_t and char32_t (not
145 - because GCC >= 4.9 defines these macros on all platforms, even on
147 We should better not use __STD_UTF_16__, __STD_UTF_32__ either, because
148 these macros are misspellings, only defined by Android's <uchar.h>. */
149 #if defined __STDC_ISO_10646__ && !_GL_SMALL_WCHAR_T
150 /* glibc, musl libc */
151 # define _GL_WCHAR_T_IS_UCS4 1
153 #if _GL_WCHAR_T_IS_UCS4
154 static_assert (sizeof (char32_t
) == sizeof (wchar_t));
158 /* Convert a single-byte character to a 32-bit wide character. */
160 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_BTOC32
162 _GL_INLINE _GL_ATTRIBUTE_PURE
wint_t
166 # if @GNULIB_BTOWC@ && defined __cplusplus && defined GNULIB_NAMESPACE
173 _GL_FUNCDECL_SYS (btoc32
, wint_t, (int c
) _GL_ATTRIBUTE_PURE
);
175 _GL_CXXALIAS_SYS (btoc32
, wint_t, (int c
));
176 _GL_CXXALIASWARN (btoc32
);
180 /* Test a specific property of a 32-bit wide character. */
181 #if @GNULIB_C32ISALNUM@
182 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALNUM
185 c32isalnum (wint_t wc
)
188 # if defined __cplusplus && defined GNULIB_NAMESPACE
195 _GL_FUNCDECL_SYS (c32isalnum
, int, (wint_t wc
));
197 _GL_CXXALIAS_SYS (c32isalnum
, int, (wint_t wc
));
198 _GL_CXXALIASWARN (c32isalnum
);
200 #if @GNULIB_C32ISALPHA@
201 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALPHA
204 c32isalpha (wint_t wc
)
207 # if defined __cplusplus && defined GNULIB_NAMESPACE
214 _GL_FUNCDECL_SYS (c32isalpha
, int, (wint_t wc
));
216 _GL_CXXALIAS_SYS (c32isalpha
, int, (wint_t wc
));
217 _GL_CXXALIASWARN (c32isalpha
);
219 #if @GNULIB_C32ISBLANK@
220 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISBLANK
223 c32isblank (wint_t wc
)
226 # if defined __cplusplus && defined GNULIB_NAMESPACE
233 _GL_FUNCDECL_SYS (c32isblank
, int, (wint_t wc
));
235 _GL_CXXALIAS_SYS (c32isblank
, int, (wint_t wc
));
236 _GL_CXXALIASWARN (c32isblank
);
238 #if @GNULIB_C32ISCNTRL@
239 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISCNTRL
242 c32iscntrl (wint_t wc
)
245 # if defined __cplusplus && defined GNULIB_NAMESPACE
252 _GL_FUNCDECL_SYS (c32iscntrl
, int, (wint_t wc
));
254 _GL_CXXALIAS_SYS (c32iscntrl
, int, (wint_t wc
));
255 _GL_CXXALIASWARN (c32iscntrl
);
257 #if @GNULIB_C32ISDIGIT@
258 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISDIGIT
261 c32isdigit (wint_t wc
)
264 # if @GNULIB_ISWDIGIT@ && defined __cplusplus && defined GNULIB_NAMESPACE
271 _GL_FUNCDECL_SYS (c32isdigit
, int, (wint_t wc
));
273 _GL_CXXALIAS_SYS (c32isdigit
, int, (wint_t wc
));
274 _GL_CXXALIASWARN (c32isdigit
);
276 #if @GNULIB_C32ISGRAPH@
277 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISGRAPH
280 c32isgraph (wint_t wc
)
283 # if defined __cplusplus && defined GNULIB_NAMESPACE
290 _GL_FUNCDECL_SYS (c32isgraph
, int, (wint_t wc
));
292 _GL_CXXALIAS_SYS (c32isgraph
, int, (wint_t wc
));
293 _GL_CXXALIASWARN (c32isgraph
);
295 #if @GNULIB_C32ISLOWER@
296 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISLOWER
299 c32islower (wint_t wc
)
302 # if defined __cplusplus && defined GNULIB_NAMESPACE
309 _GL_FUNCDECL_SYS (c32islower
, int, (wint_t wc
));
311 _GL_CXXALIAS_SYS (c32islower
, int, (wint_t wc
));
312 _GL_CXXALIASWARN (c32islower
);
314 #if @GNULIB_C32ISPRINT@
315 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPRINT
318 c32isprint (wint_t wc
)
321 # if defined __cplusplus && defined GNULIB_NAMESPACE
328 _GL_FUNCDECL_SYS (c32isprint
, int, (wint_t wc
));
330 _GL_CXXALIAS_SYS (c32isprint
, int, (wint_t wc
));
331 _GL_CXXALIASWARN (c32isprint
);
333 #if @GNULIB_C32ISPUNCT@
334 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPUNCT
337 c32ispunct (wint_t wc
)
340 # if defined __cplusplus && defined GNULIB_NAMESPACE
347 _GL_FUNCDECL_SYS (c32ispunct
, int, (wint_t wc
));
349 _GL_CXXALIAS_SYS (c32ispunct
, int, (wint_t wc
));
350 _GL_CXXALIASWARN (c32ispunct
);
352 #if @GNULIB_C32ISSPACE@
353 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISSPACE
356 c32isspace (wint_t wc
)
359 # if defined __cplusplus && defined GNULIB_NAMESPACE
366 _GL_FUNCDECL_SYS (c32isspace
, int, (wint_t wc
));
368 _GL_CXXALIAS_SYS (c32isspace
, int, (wint_t wc
));
369 _GL_CXXALIASWARN (c32isspace
);
371 #if @GNULIB_C32ISUPPER@
372 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISUPPER
375 c32isupper (wint_t wc
)
378 # if defined __cplusplus && defined GNULIB_NAMESPACE
385 _GL_FUNCDECL_SYS (c32isupper
, int, (wint_t wc
));
387 _GL_CXXALIAS_SYS (c32isupper
, int, (wint_t wc
));
388 _GL_CXXALIASWARN (c32isupper
);
390 #if @GNULIB_C32ISXDIGIT@
391 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISXDIGIT
394 c32isxdigit (wint_t wc
)
397 # if @GNULIB_ISWXDIGIT@ && defined __cplusplus && defined GNULIB_NAMESPACE
404 _GL_FUNCDECL_SYS (c32isxdigit
, int, (wint_t wc
));
406 _GL_CXXALIAS_SYS (c32isxdigit
, int, (wint_t wc
));
407 _GL_CXXALIASWARN (c32isxdigit
);
411 /* Case mapping of a 32-bit wide character. */
412 #if @GNULIB_C32TOLOWER@
413 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOLOWER
416 c32tolower (wint_t wc
)
419 # if defined __cplusplus && defined GNULIB_NAMESPACE
426 _GL_FUNCDECL_SYS (c32tolower
, wint_t, (wint_t wc
));
428 _GL_CXXALIAS_SYS (c32tolower
, wint_t, (wint_t wc
));
429 _GL_CXXALIASWARN (c32tolower
);
431 #if @GNULIB_C32TOUPPER@
432 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOUPPER
435 c32toupper (wint_t wc
)
438 # if defined __cplusplus && defined GNULIB_NAMESPACE
445 _GL_FUNCDECL_SYS (c32toupper
, wint_t, (wint_t wc
));
447 _GL_CXXALIAS_SYS (c32toupper
, wint_t, (wint_t wc
));
448 _GL_CXXALIASWARN (c32toupper
);
452 /* Number of screen columns needed for a 32-bit wide character. */
453 #if @GNULIB_C32WIDTH@
454 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32WIDTH
457 c32width (char32_t wc
)
460 # if @GNULIB_WCWIDTH@ && defined __cplusplus && defined GNULIB_NAMESPACE
467 _GL_FUNCDECL_SYS (c32width
, int, (char32_t wc
));
469 _GL_CXXALIAS_SYS (c32width
, int, (char32_t wc
));
470 _GL_CXXALIASWARN (c32width
);
474 /* Converts a 32-bit wide character to a multibyte character. */
475 #if @GNULIB_C32RTOMB@
476 # if @REPLACE_C32RTOMB@
477 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
479 # define c32rtomb rpl_c32rtomb
481 _GL_FUNCDECL_RPL (c32rtomb
, size_t, (char *s
, char32_t wc
, mbstate_t *ps
));
482 _GL_CXXALIAS_RPL (c32rtomb
, size_t, (char *s
, char32_t wc
, mbstate_t *ps
));
484 # if !@HAVE_C32RTOMB@
485 _GL_FUNCDECL_SYS (c32rtomb
, size_t, (char *s
, char32_t wc
, mbstate_t *ps
));
487 _GL_CXXALIAS_SYS (c32rtomb
, size_t, (char *s
, char32_t wc
, mbstate_t *ps
));
489 # if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
490 _GL_CXXALIASWARN (c32rtomb
);
492 #elif defined GNULIB_POSIXCHECK
494 # if HAVE_RAW_DECL_C32RTOMB
495 _GL_WARN_ON_USE (c32rtomb
, "c32rtomb is not portable - "
496 "use gnulib module c32rtomb for portability");
501 /* Convert a 32-bit wide string to a string. */
502 #if @GNULIB_C32SNRTOMBS@
503 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SNRTOMBS
505 _GL_INLINE
_GL_ARG_NONNULL ((2)) size_t
506 c32snrtombs (char *dest
, const char32_t
**srcp
, size_t srclen
, size_t len
,
510 # if @GNULIB_WCSNRTOMBS@ && defined __cplusplus && defined GNULIB_NAMESPACE
513 wcsnrtombs (dest
, (const wchar_t **) srcp
, srclen
, len
, ps
);
517 _GL_FUNCDECL_SYS (c32snrtombs
, size_t,
518 (char *dest
, const char32_t
**srcp
, size_t srclen
, size_t len
,
520 _GL_ARG_NONNULL ((2)));
522 _GL_CXXALIAS_SYS (c32snrtombs
, size_t,
523 (char *dest
, const char32_t
**srcp
, size_t srclen
, size_t len
,
525 _GL_CXXALIASWARN (c32snrtombs
);
529 /* Convert a 32-bit wide string to a string. */
530 #if @GNULIB_C32SRTOMBS@
531 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SRTOMBS
533 _GL_INLINE
_GL_ARG_NONNULL ((2)) size_t
534 c32srtombs (char *dest
, const char32_t
**srcp
, size_t len
, mbstate_t *ps
)
537 # if @GNULIB_WCSRTOMBS@ && defined __cplusplus && defined GNULIB_NAMESPACE
540 wcsrtombs (dest
, (const wchar_t **) srcp
, len
, ps
);
544 _GL_FUNCDECL_SYS (c32srtombs
, size_t,
545 (char *dest
, const char32_t
**srcp
, size_t len
, mbstate_t *ps
)
546 _GL_ARG_NONNULL ((2)));
548 _GL_CXXALIAS_SYS (c32srtombs
, size_t,
549 (char *dest
, const char32_t
**srcp
, size_t len
,
551 _GL_CXXALIASWARN (c32srtombs
);
555 /* Convert a 32-bit wide string to a string. */
556 #if @GNULIB_C32STOMBS@
557 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32STOMBS
559 _GL_INLINE
_GL_ARG_NONNULL ((2)) size_t
560 c32stombs (char *dest
, const char32_t
*src
, size_t len
)
565 return c32srtombs (dest
, &src
, len
, &state
);
569 _GL_FUNCDECL_SYS (c32stombs
, size_t,
570 (char *dest
, const char32_t
*src
, size_t len
)
571 _GL_ARG_NONNULL ((2)));
573 _GL_CXXALIAS_SYS (c32stombs
, size_t,
574 (char *dest
, const char32_t
*src
, size_t len
));
575 _GL_CXXALIASWARN (c32stombs
);
579 /* Number of screen columns needed for a size-bounded 32-bit wide string. */
580 #if @GNULIB_C32SWIDTH@
581 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32SWIDTH
583 _GL_INLINE
_GL_ARG_NONNULL ((1)) int
584 c32swidth (const char32_t
*s
, size_t n
)
587 # if @GNULIB_WCSWIDTH@ && defined __cplusplus && defined GNULIB_NAMESPACE
590 wcswidth ((const wchar_t *) s
, n
);
594 _GL_FUNCDECL_SYS (c32swidth
, int, (const char32_t
*s
, size_t n
)
595 _GL_ARG_NONNULL ((1)));
597 _GL_CXXALIAS_SYS (c32swidth
, int, (const char32_t
*s
, size_t n
));
598 _GL_CXXALIASWARN (c32swidth
);
602 /* Converts a 32-bit wide character to unibyte character.
603 Returns the single-byte representation of WC if it exists,
606 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32TOB
612 # if @GNULIB_WCTOB@ && defined __cplusplus && defined GNULIB_NAMESPACE
619 _GL_FUNCDECL_SYS (c32tob
, int, (wint_t wc
));
621 _GL_CXXALIAS_SYS (c32tob
, int, (wint_t wc
));
622 _GL_CXXALIASWARN (c32tob
);
626 /* Converts a multibyte character to a 32-bit wide character. */
627 #if @GNULIB_MBRTOC32@
628 # if @REPLACE_MBRTOC32@
629 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
631 # define mbrtoc32 rpl_mbrtoc32
633 _GL_FUNCDECL_RPL (mbrtoc32
, size_t,
634 (char32_t
*pc
, const char *s
, size_t n
, mbstate_t *ps
));
635 _GL_CXXALIAS_RPL (mbrtoc32
, size_t,
636 (char32_t
*pc
, const char *s
, size_t n
, mbstate_t *ps
));
638 # if !@HAVE_MBRTOC32@
639 _GL_FUNCDECL_SYS (mbrtoc32
, size_t,
640 (char32_t
*pc
, const char *s
, size_t n
, mbstate_t *ps
));
642 _GL_CXXALIAS_SYS (mbrtoc32
, size_t,
643 (char32_t
*pc
, const char *s
, size_t n
, mbstate_t *ps
));
645 # if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
646 _GL_CXXALIASWARN (mbrtoc32
);
648 #elif defined GNULIB_POSIXCHECK
650 # if HAVE_RAW_DECL_MBRTOC32
651 _GL_WARN_ON_USE (mbrtoc32
, "mbrtoc32 is not portable - "
652 "use gnulib module mbrtoc32 for portability");
657 /* Converts a multibyte character and returns the next 16-bit wide
659 #if @GNULIB_MBRTOC16@
660 # if @REPLACE_MBRTOC16@
661 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
663 # define mbrtoc16 rpl_mbrtoc16
665 _GL_FUNCDECL_RPL (mbrtoc16
, size_t,
666 (char16_t
*pc
, const char *s
, size_t n
, mbstate_t *ps
));
667 _GL_CXXALIAS_RPL (mbrtoc16
, size_t,
668 (char16_t
*pc
, const char *s
, size_t n
, mbstate_t *ps
));
670 # if !@HAVE_MBRTOC32@
671 _GL_FUNCDECL_SYS (mbrtoc16
, size_t,
672 (char16_t
*pc
, const char *s
, size_t n
, mbstate_t *ps
));
674 _GL_CXXALIAS_SYS (mbrtoc16
, size_t,
675 (char16_t
*pc
, const char *s
, size_t n
, mbstate_t *ps
));
677 # if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
678 _GL_CXXALIASWARN (mbrtoc16
);
680 #elif defined GNULIB_POSIXCHECK
682 # if HAVE_RAW_DECL_MBRTOC16
683 _GL_WARN_ON_USE (mbrtoc16
, "mbrtoc16 is not portable - "
684 "use gnulib module mbrtoc16 for portability");
689 /* Convert a string to a 32-bit wide string. */
690 #if @GNULIB_MBSNRTOC32S@
691 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSNRTOC32S
693 _GL_INLINE
_GL_ARG_NONNULL ((2)) size_t
694 mbsnrtoc32s (char32_t
*dest
, const char **srcp
, size_t srclen
, size_t len
,
698 # if @GNULIB_MBSNRTOWCS@ && defined __cplusplus && defined GNULIB_NAMESPACE
701 mbsnrtowcs ((wchar_t *) dest
, srcp
, srclen
, len
, ps
);
705 _GL_FUNCDECL_SYS (mbsnrtoc32s
, size_t,
706 (char32_t
*dest
, const char **srcp
, size_t srclen
, size_t len
,
708 _GL_ARG_NONNULL ((2)));
710 _GL_CXXALIAS_SYS (mbsnrtoc32s
, size_t,
711 (char32_t
*dest
, const char **srcp
, size_t srclen
, size_t len
,
713 _GL_CXXALIASWARN (mbsnrtoc32s
);
717 /* Convert a string to a 32-bit wide string. */
718 #if @GNULIB_MBSRTOC32S@
719 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSRTOC32S
721 _GL_INLINE
_GL_ARG_NONNULL ((2)) size_t
722 mbsrtoc32s (char32_t
*dest
, const char **srcp
, size_t len
, mbstate_t *ps
)
725 # if @GNULIB_MBSRTOWCS@ && defined __cplusplus && defined GNULIB_NAMESPACE
728 mbsrtowcs ((wchar_t *) dest
, srcp
, len
, ps
);
732 _GL_FUNCDECL_SYS (mbsrtoc32s
, size_t,
733 (char32_t
*dest
, const char **srcp
, size_t len
, mbstate_t *ps
)
734 _GL_ARG_NONNULL ((2)));
736 _GL_CXXALIAS_SYS (mbsrtoc32s
, size_t,
737 (char32_t
*dest
, const char **srcp
, size_t len
,
739 _GL_CXXALIASWARN (mbsrtoc32s
);
743 /* Convert a string to a 32-bit wide string. */
744 #if @GNULIB_MBSTOC32S@
745 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSTOC32S
747 _GL_INLINE
_GL_ARG_NONNULL ((2)) size_t
748 mbstoc32s (char32_t
*dest
, const char *src
, size_t len
)
753 return mbsrtoc32s (dest
, &src
, len
, &state
);
757 _GL_FUNCDECL_SYS (mbstoc32s
, size_t,
758 (char32_t
*dest
, const char *src
, size_t len
)
759 _GL_ARG_NONNULL ((2)));
761 _GL_CXXALIAS_SYS (mbstoc32s
, size_t,
762 (char32_t
*dest
, const char *src
, size_t len
));
763 _GL_CXXALIASWARN (mbstoc32s
);
767 #if @GNULIB_C32_GET_TYPE_TEST@ || @GNULIB_C32_APPLY_TYPE_TEST@
768 /* A scalar type. Instances of this type, other than (c32_type_test_t) 0,
769 represent a character property, sometimes also viewed as a "character class".
770 It can be applied to 32-bit wide characters. It is the counterpart of
771 type 'wctype_t' for wide characters.
772 To test whether a given character has a certain property, use the function
773 'c32_apply_type_test'. */
774 # if _GL_WCHAR_T_IS_UCS4
775 typedef wctype_t c32_type_test_t
;
777 typedef /*bool*/int (*c32_type_test_t
) (wint_t wc
);
781 /* Return a character property with the given name, or (c32_type_test_t) 0
782 if the designated property does not exist.
783 This function is the counterpart of function 'wctype' for wide characters.
785 #if @GNULIB_C32_GET_TYPE_TEST@
786 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_TYPE_TEST
788 _GL_INLINE
_GL_ARG_NONNULL ((1)) c32_type_test_t
789 c32_get_type_test (const char *name
)
792 # if @GNULIB_WCTYPE@ && defined __cplusplus && defined GNULIB_NAMESPACE
799 _GL_FUNCDECL_SYS (c32_get_type_test
, c32_type_test_t
, (const char *name
)
800 _GL_ARG_NONNULL ((1)));
802 _GL_CXXALIAS_SYS (c32_get_type_test
, c32_type_test_t
, (const char *name
));
803 _GL_CXXALIASWARN (c32_get_type_test
);
806 /* Test whether a given 32-bit wide character has the specified character
808 Return non-zero if true, zero if false or if the argument is WEOF.
809 This function is the counterpart of function 'iswctype' for wide characters.
811 #if @GNULIB_C32_APPLY_TYPE_TEST@
812 # if _GL_WCHAR_T_IS_UCS4
813 # if !defined IN_C32_APPLY_TYPE_TEST
816 c32_apply_type_test (wint_t wc
, c32_type_test_t property
)
819 # if @GNULIB_ISWCTYPE@ && defined __cplusplus && defined GNULIB_NAMESPACE
822 iswctype (wc
, property
);
826 _GL_FUNCDECL_SYS (c32_apply_type_test
, int,
827 (wint_t wc
, c32_type_test_t property
));
830 _GL_FUNCDECL_SYS (c32_apply_type_test
, int,
831 (wint_t wc
, c32_type_test_t property
)
832 _GL_ARG_NONNULL ((2)));
834 _GL_CXXALIAS_SYS (c32_apply_type_test
, int,
835 (wint_t wc
, c32_type_test_t property
));
836 _GL_CXXALIASWARN (c32_apply_type_test
);
840 #if @GNULIB_C32_GET_MAPPING@ || @GNULIB_C32_APPLY_MAPPING@
841 /* A scalar type. Instances of this type, other than (c32_mapping_t) 0,
842 represent a character mapping. It can be applied to 32-bit wide characters.
843 It is the counterpart of type 'wctrans_t' for wide characters.
844 To apply a certain mapping to a given character, use the function
845 'c32_apply_mapping'. */
846 # if _GL_WCHAR_T_IS_UCS4
847 typedef wctrans_t c32_mapping_t
;
849 typedef wint_t (*c32_mapping_t
) (wint_t wc
);
853 /* Return a character mapping with the given name, or (c32_mapping_t) 0
854 if the designated mapping does not exist.
855 This function is the counterpart of function 'wctrans' for wide characters.
857 #if @GNULIB_C32_GET_MAPPING@
858 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_MAPPING
860 _GL_INLINE
_GL_ARG_NONNULL ((1)) c32_mapping_t
861 c32_get_mapping (const char *name
)
864 # if @GNULIB_WCTRANS@ && defined __cplusplus && defined GNULIB_NAMESPACE
871 _GL_FUNCDECL_SYS (c32_get_mapping
, c32_mapping_t
, (const char *name
)
872 _GL_ARG_NONNULL ((1)));
874 _GL_CXXALIAS_SYS (c32_get_mapping
, c32_mapping_t
, (const char *name
));
875 _GL_CXXALIASWARN (c32_get_mapping
);
878 /* Apply the specified character mapping to a given 32-bit wide character.
879 Return the result of this mapping. Return the WC argument unchanged if it is
881 This function is the counterpart of function 'towctrans' for wide characters.
883 #if @GNULIB_C32_APPLY_MAPPING@
884 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_APPLY_MAPPING
886 _GL_INLINE
_GL_ARG_NONNULL ((2)) wint_t
887 c32_apply_mapping (wint_t wc
, c32_mapping_t mapping
)
890 # if @GNULIB_TOWCTRANS@ && defined __cplusplus && defined GNULIB_NAMESPACE
893 towctrans (wc
, mapping
);
897 _GL_FUNCDECL_SYS (c32_apply_mapping
, wint_t,
898 (wint_t wc
, c32_mapping_t mapping
)
899 _GL_ARG_NONNULL ((2)));
901 _GL_CXXALIAS_SYS (c32_apply_mapping
, wint_t,
902 (wint_t wc
, c32_mapping_t mapping
));
903 _GL_CXXALIASWARN (c32_apply_mapping
);
907 _GL_INLINE_HEADER_END
909 #endif /* _@GUARD_PREFIX@_UCHAR_H */
910 #endif /* _@GUARD_PREFIX@_UCHAR_H */