
mbrtoc16
493
i += rv; // rv != -3
}
}
else
{
count = -1;
}
break;
}
} while (count > 0 && i < nBytes);
return count;
}
int main(void)
{
if (setlocale(LC_ALL, "en_US.utf8") == NULL)
{
fputs("Unable to set the locale.\n", stderr);
}
const char* u8Str = u8"Grüße";
char16_t c16
Str[100];
int nChars = mbsToC16s(u8Str, c16Str, (sizeof(c16Str)/sizeof(c16Str[0])));
if (nChars < 0)
{
fputs("Error ...", stderr);
}
else
{
printf("%d UTF-16 characters.\n", nChars);
// ...
}
return 0;
}
関数呼び出し例
int main(void)
{
if (setlocale(LC_ALL, "en_US.utf8") == NULL)
{
fputs("Unable to set the locale.\n", stderr);
}
char* u8Str = u8"Gruse";
char16_t
c16Str[100];
int nChars ...