uchar C++ tests: Fix build error on FreeBSD 12.
[gnulib.git] / lib / c32snrtombs.c
blobbd47e309c5d20cb6c9e5407641606a4da56a86da
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 c32snrtombs
37 # define SCHAR_T char32_t
38 # define INTERNAL_STATE _gl_c32srtombs_state
39 # define WCRTOMB c32rtomb
40 # include "wcsnrtombs-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 c32snrtombs (char *dest, const char32_t **srcp, size_t srclen, size_t len,
51 mbstate_t *ps)
53 return wcsnrtombs (dest, (const wchar_t **) srcp, srclen, len, ps);
56 #endif