about summary refs log tree commit diff
path: root/src/multibyte/mbrtoc32.c
blob: c6d2082419e452db5acb64dbc27426c2550e5baf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
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;
}