summaryrefslogtreecommitdiff
path: root/lib/mbstoc32s.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-01-05 12:23:00 +0100
committerBruno Haible <bruno@clisp.org>2020-01-05 12:23:00 +0100
commit8208c314448c4a26beda29b9666a5626521b7312 (patch)
treecb678a59f8406d24f9c7dc919f90afb412086d72 /lib/mbstoc32s.c
parent888c04969a2a067ad6a4ed75cf3461e34765ee51 (diff)
downloadgnulib-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.c33
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);
+}