havelib: Fix for Solaris 11 OpenIndiana and Solaris 11 OmniOS.
[gnulib.git] / lib / c32srtombs.c
bloba4e08407dd4d465c0f20a9607181606e02e25abf
1 /* Convert 32-bit wide string to string.
2 Copyright (C) 2020 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program 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 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2020. */
19 #include <config.h>
21 /* Specification. */
22 #include <uchar.h>
24 #include <wchar.h>
26 #if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_LARGE_CHAR32_T
27 /* The char32_t encoding of a multibyte character may be different than its
28 wchar_t encoding, or char32_t is wider than wchar_t. */
30 # include <errno.h>
31 # include <stdlib.h>
32 # include <string.h>
34 extern mbstate_t _gl_c32srtombs_state;
36 # define FUNC c32srtombs
37 # define SCHAR_T char32_t
38 # define INTERNAL_STATE _gl_c32srtombs_state
39 # define WCRTOMB c32rtomb
40 # include "wcsrtombs-impl.h"
42 #else
43 /* char32_t and wchar_t are equivalent. */
45 # include "verify.h"
47 verify (sizeof (char32_t) == sizeof (wchar_t));
49 size_t
50 c32srtombs (char *dest, const char32_t **srcp, size_t len, mbstate_t *ps)
52 return wcsrtombs (dest, (const wchar_t **) srcp, len, ps);
55 #endif