diff options
author | Bruno Haible <bruno@clisp.org> | 2020-01-05 12:23:00 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-01-05 12:23:00 +0100 |
commit | 8208c314448c4a26beda29b9666a5626521b7312 (patch) | |
tree | cb678a59f8406d24f9c7dc919f90afb412086d72 /lib/mbstoc32s.c | |
parent | 888c04969a2a067ad6a4ed75cf3461e34765ee51 (diff) | |
download | gnulib-8208c314448c4a26beda29b9666a5626521b7312.tar.gz |
mbstoc32s: New module.
* lib/uchar.in.h (mbstoc32s): New declaration.
* lib/mbstoc32s.c: New file.
* m4/uchar.m4 (gl_UCHAR_H_DEFAULTS): Initialize GNULIB_MBSTOC32S.
* modules/uchar (Makefile.am): Substitute GNULIB_MBSTOC32S.
* modules/mbstoc32s: New file.
* tests/test-uchar-c++.cc: Test the signature of mbstoc32s.
* doc/posix-functions/mbstowcs.texi: Mention the new module.
Diffstat (limited to 'lib/mbstoc32s.c')
-rw-r--r-- | lib/mbstoc32s.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/mbstoc32s.c b/lib/mbstoc32s.c new file mode 100644 index 0000000000..ede2786628 --- /dev/null +++ b/lib/mbstoc32s.c @@ -0,0 +1,33 @@ +/* Convert string to 32-bit wide string. + Copyright (C) 2020 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2020. + + 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/>. */ + +#include <config.h> + +/* Specification. */ +#include <uchar.h> + +#include <string.h> +#include <wchar.h> + +size_t +mbstoc32s (char32_t *dest, const char *src, size_t len) +{ + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + return mbsrtoc32s (dest, &src, len, &state); +} |