#include <locale.h>
#include <string.h>
#include <stdio.h>
#include <wchar.h>
int main(void)
{
setlocale(LC_ALL, "en_US.utf8");
const char* str = u8"水"; static mbstate_t mb; (void)mbrlen(&str[0], 1, &mb);
if (!mbsinit(&mb)) {
printf("After processing the first 1 byte of %s,\n"
"the conversion state is not initial\n\n", str);
}
(void)mbrlen(&str[1], strlen(str), &mb);
if (mbsinit(&mb)) {
printf("After processing the remaining 2 bytes of %s,\n"
"the conversion state is initial conversion state\n", str);
}
}