#include <bits/stdc++.h>
using
namespace
std;
void
check_(
const
char
* str,
size_t
n)
{
mbstate_t
ps =
mbstate_t
();
int
returnV = mbrlen(str, n, &ps);
if
(returnV == -2)
cout <<
"Next "
<< n <<
" byte(s) doesn't"
<<
" represent a complete"
<<
" multibyte character"
<< endl;
else
if
(returnV == -1)
cout <<
"Next "
<< n <<
" byte(s) doesn't "
<<
"represent a valid multibyte character"
<< endl;
else
cout <<
"Next "
<< n <<
" byte(s) of "
<< str <<
"holds "
<< returnV <<
" byte"
<<
" multibyte character"
<< endl;
}
int
main()
{
setlocale
(LC_ALL,
"en_US.utf8"
);
char
str[] =
"\u10000b5"
;
check_(str, 1);
check_(str, 6);
return
0;
}