utf8 decoding fix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15841 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-02-01 06:39:37 +00:00
parent c722e7f062
commit 11cb628f81
2 changed files with 11 additions and 6 deletions

View file

@ -1048,7 +1048,7 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
break;
}
c1 = src[spos++];
if (!((c1 ^ 0x80) < 0x40))
if ((c1 ^ 0x80) >= 0x40)
{
/*
* Second byte in sequence is not a legal
@ -1057,7 +1057,7 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
result = NO;
break;
}
u = ((c & 0x1f) << 6) | (c1 ^ 0x80);
u = ((c & 0x1f) << 6) | (c1 & 0x3f);
}
else if (c < 0xf0)
{
@ -1071,14 +1071,14 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
break;
}
c2 = src[spos++];
if (!(((c1 ^ 0x80) < 0x40) && ((c2 ^ 0x80) < 0x40)
&& (c1 >= 0xa0)))
if (((c1 ^ 0x80) >= 0x40) || ((c2 ^ 0x80) >= 0x40)
|| (c1 == 0x80))
{
result = NO; // Invalid sequence.
break;
}
u = ((c & 0x0f) << 12) | ((c1 ^ 0x80) << 6)
| (c2 ^ 0x80);
u = ((c & 0x0f) << 12) | ((c1 & 0x3f) << 6)
| (c2 & 0x3f);
}
else
{