Using following custom function:
int strlen_utf8(char *s)
{
int i = 0, j = 0;
while (s[i])
{
if ((s[i] & 0xc0) != 0x80)
j++;
i++;
}
return j;
}
Let's say if string contains japanese word(5 japanese characters) with 10 bytes at binary level, it will return 5.
In case if string contains 5 ASCII characters (5 bytes at binary level ), it will return 5.
Anybody see any problem in this ?
|