1 /* Convert 32-bit wide string to string. 2 Copyright (C) 2020-2021 Free Software Foundation, Inc. 3 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 3 of the 7 License, or (at your option) any later version. 8 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. 13 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/>. */ 16 17 /* Written by Bruno Haible <bruno@clisp.org>, 2020. */ 18 19 #include <config.h> 20 21 /* Specification. */ 22 #include <uchar.h> 23 24 #include <wchar.h> 25 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. */ 29 30 # include <errno.h> 31 # include <stdlib.h> 32 # include <string.h> 33 34 extern mbstate_t _gl_c32srtombs_state; 35 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" 41 42 #else 43 /* char32_t and wchar_t are equivalent. */ 44 45 # include "verify.h" 46 47 verify (sizeof (char32_t) == sizeof (wchar_t)); 48 49 size_t 50 c32snrtombs (char *dest, const char32_t **srcp, size_t srclen, size_t len, /* */ 51 mbstate_t *ps) 52 { 53 return wcsnrtombs (dest, (const wchar_t **) srcp, srclen, len, ps); 54 } 55 56 #endif