#include #include #include #include #include #include #include int main () { assert (setlocale (LC_ALL, "en_US.UTF-8") != NULL); mbstate_t state; memset (&state, 0, sizeof (state)); char32_t uc = 0xDEADBEEF; size_t bytes; /* \360\237\220\203 = U+0001F403 */ bytes = mbrtoc32 (&uc, "\360", 1, &state); assert (bytes == (size_t)-2); bytes = mbrtoc32 (&uc, "\237", 1, &state); assert (bytes == (size_t)-2); bytes = mbrtoc32 (&uc, "\220", 1, &state); assert (bytes == (size_t)-2); bytes = mbrtoc32 (&uc, "\203", 1, &state); assert (bytes == 1); assert (uc == 0x0001F403); } /* Works in: glibc, musl libc, FreeBSD 14.0, Solaris 11.4 Fails in: Cygwin 3.5.3 */