mbrtoc32.c 354 B

12345678910111213
  1. #include <uchar.h>
  2. #include <wchar.h>
  3. size_t mbrtoc32(char32_t *restrict pc32, const char *restrict s, size_t n, mbstate_t *restrict ps)
  4. {
  5. static unsigned internal_state;
  6. if (!ps) ps = (void *)&internal_state;
  7. if (!s) return mbrtoc32(0, "", 1, ps);
  8. wchar_t wc;
  9. size_t ret = mbrtowc(&wc, s, n, ps);
  10. if (ret <= 4 && pc32) *pc32 = wc;
  11. return ret;
  12. }