10 if (setlocale (LC_ALL
, "de_DE.UTF-8") == NULL
)
12 puts ("cannot set locale");
21 if (c32
>= 0xd800 && c32
<= 0xe000)
25 size_t n1
= c32rtomb (buf
, c32
, NULL
);
28 printf ("c32rtomb for U'\\x%" PRIx32
"' failed\n", (uint32_t) c32
);
34 size_t n2
= mbrtoc32 (&c32out
, buf
, n1
, NULL
);
37 printf ("mbrtoc32 for U'\\x%" PRIx32
"' failed\n", (uint32_t) c32
);
43 printf ("mbrtoc32 for U'\\x%" PRIx32
"' consumed %zu bytes, not %zu\n",
44 (uint32_t) c32
, n2
, n1
);
47 else if (c32out
!= c32
)
49 printf ("mbrtoc32 for U'\\x%" PRIx32
"' produced U'\\x%" PRIx32
"\n",
50 (uint32_t) c32
, (uint32_t) c32out
);
55 size_t n3
= mbrtoc16 (&c16
, buf
, n1
, NULL
);
58 printf ("mbrtoc16 for U'\\x%" PRIx32
"' did not consume all bytes\n",
67 printf ("mbrtoc16 for U'\\x%" PRIx32
"' produce u'\\x%" PRIx16
"'\n",
68 (uint32_t) c32
, (uint16_t) c16
);
77 size_t n4
= mbrtoc16 (&c16_2
, buf
, 1, NULL
);
78 if (n4
!= (size_t) -3)
80 printf ("second mbrtoc16 for U'\\x%" PRIx32
"' did not return -3\n",
86 if (c32
!= (((uint32_t) (c16
- 0xd7c0)) << 10) + (c16_2
- 0xdc00))
88 printf ("mbrtoc16 for U'\\x%" PRIx32
"' returns U'\\x%" PRIx32
"\n",
90 (((uint32_t) (c16
- 0xd7c0)) << 10) + (c16_2
- 0xdc00));
98 n3
= mbrtoc16 (&c16_nul
, buf
, n1
, NULL
);
101 printf ("mbrtoc16 for '\\0' returns %zd\n", n3
);
108 size_t n5
= c16rtomb (buf
, c16
, NULL
);
109 if ((ssize_t
) n5
< 0)
111 printf ("c16rtomb for U'\\x%" PRIx32
"' failed with %zd\n",
118 printf ("c16rtomb for U'\\x%" PRIx32
"' produced %zu bytes instead of %zu bytes\n",
119 (uint32_t) c32
, n5
, n1
);
125 while ((c32
+= 0x1111) <= U
'\x12000');
130 #define TEST_FUNCTION do_test ()
131 #include "../test-skeleton.c"