about summary refs log tree commit diff
path: root/src/multibyte/mbrtoc32.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-10-13 20:59:42 -0400
committerRich Felker <dalias@aerifal.cx>2014-10-13 20:59:42 -0400
commitab9672ae73248f51e30f4553c4b8878525e46383 (patch)
treefd3cfee2bcc10a64b83009af92f0de09703dfa75 /src/multibyte/mbrtoc32.c
parent00548408398ced546c540dab773ea66cea4fe1c2 (diff)
downloadmusl-ab9672ae73248f51e30f4553c4b8878525e46383.tar.gz
musl-ab9672ae73248f51e30f4553c4b8878525e46383.tar.xz
musl-ab9672ae73248f51e30f4553c4b8878525e46383.zip
implement uchar.h (C11 UTF-16/32 conversion) interfaces
Diffstat (limited to 'src/multibyte/mbrtoc32.c')
-rw-r--r--src/multibyte/mbrtoc32.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/multibyte/mbrtoc32.c b/src/multibyte/mbrtoc32.c
new file mode 100644
index 00000000..c6d20824
--- /dev/null
+++ b/src/multibyte/mbrtoc32.c
@@ -0,0 +1,11 @@
+#include <uchar.h>
+#include <wchar.h>
+
+size_t mbrtoc32(char32_t *restrict pc32, const char *restrict s, size_t n, mbstate_t *restrict ps)
+{
+	if (!s) return mbrtoc32(0, "", 1, ps);
+	wchar_t wc;
+	size_t ret = mbrtowc(&wc, s, n, ps);
+	if (ret <= 4 && pc32) *pc32 = wc;
+	return ret;
+}