Commit 0b49b59c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

IsUTF8: use clz

parent 15b6bc54
......@@ -286,25 +286,20 @@ static char *CheckUTF8( char *str, char rep )
for (;;)
{
uint8_t c = ptr[0];
int charlen = -1;
if (c == '\0')
break;
for (int i = 0; i < 7; i++)
if ((c >> (7 - i)) == ((0xff >> (7 - i)) ^ 1))
{
charlen = i;
break;
}
if (c > 0xF4)
goto error;
int charlen = clz8 (c ^ 0xFF);
switch (charlen)
{
case 0: // 7-bit ASCII character -> OK
ptr++;
continue;
case -1: // 1111111x -> error
case 1: // continuation byte -> error
goto error;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment