Lets say I have this string
const char* ch = "ب";
printf("%zu\n", strlen(ch));
result is 2
how I count the unicode "ب" as 1 character ?
Answer
int
name_len(const char *ch)
{
int i = 0;
int j = 0;
while (ch[i] != '\0') {
if ((ch[i] & 0xC0) != 0x80)
++ j;
++ i;
}
return j;
}