Index: unicode.h =================================================================== RCS file: /cvsroot/src/sys/fs/unicode.h,v retrieving revision 1.5 diff -u -r1.5 unicode.h --- unicode.h 26 Feb 2007 12:33:08 -0000 1.5 +++ unicode.h 27 Feb 2007 07:20:17 -0000 @@ -83,7 +83,7 @@ static u_int16_t wget_utf8(const char **str, size_t *sz) { - int c; + int c, n; u_int16_t rune = 0; const char *s = *str; static const int _utf_count[16] = { @@ -123,6 +123,16 @@ | (s[2] & 0x3F); break; } + if (rune & 0xf800) + n = 3; + else if (rune & 0x0780) + n = 2; + else + n = 1; + if (c != n) { + c = 1; + rune = s[0] & 0xff; + } *str += c; *sz -= c;