Hi Dietmar!

On 14.08.2014 08:21, dietmar.schind...@manroland-web.com wrote:
> These do not work if char is signed.
You are right, I missed the type casts ... sorry


size_t utf8len( const char* s )
{
   size_t n = 0;
   while (*s)
     if ((unsigned char)(*s++ ^ 0x40) < (unsigned char)0xC0)
       n++;
    return n;
}

char *utf8skip( char const* s, size_t n )
{
   for ( ; n && *s; --n )
      while ((unsigned char)(*++s ^ 0x40) >= (unsigned char)0xC0);
   return (char*)s;
}


I know, most would prefer to use (unsigned char) ahead of *++s or *s++, but at least gcc gave better optimized x86 code for my type casts.

--
Harald
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to