mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 01:21:08 +00:00
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:
parent
1c438728a3
commit
e5b300c58f
2 changed files with 11 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-02-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/Additions/Unicode.m: Fix error in check for legality of
|
||||||
|
three-byte utf-8 sequences.
|
||||||
|
|
||||||
2003-01-31 Richard Frith-Macdonald <rfm@gnu.org>
|
2003-01-31 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSRunLoop.m: Fix memory leak with timed performs.
|
* Source/NSRunLoop.m: Fix memory leak with timed performs.
|
||||||
|
|
|
@ -1048,7 +1048,7 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
c1 = src[spos++];
|
c1 = src[spos++];
|
||||||
if (!((c1 ^ 0x80) < 0x40))
|
if ((c1 ^ 0x80) >= 0x40)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Second byte in sequence is not a legal
|
* Second byte in sequence is not a legal
|
||||||
|
@ -1057,7 +1057,7 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
|
||||||
result = NO;
|
result = NO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
u = ((c & 0x1f) << 6) | (c1 ^ 0x80);
|
u = ((c & 0x1f) << 6) | (c1 & 0x3f);
|
||||||
}
|
}
|
||||||
else if (c < 0xf0)
|
else if (c < 0xf0)
|
||||||
{
|
{
|
||||||
|
@ -1071,14 +1071,14 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
c2 = src[spos++];
|
c2 = src[spos++];
|
||||||
if (!(((c1 ^ 0x80) < 0x40) && ((c2 ^ 0x80) < 0x40)
|
if (((c1 ^ 0x80) >= 0x40) || ((c2 ^ 0x80) >= 0x40)
|
||||||
&& (c1 >= 0xa0)))
|
|| (c1 == 0x80))
|
||||||
{
|
{
|
||||||
result = NO; // Invalid sequence.
|
result = NO; // Invalid sequence.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
u = ((c & 0x0f) << 12) | ((c1 ^ 0x80) << 6)
|
u = ((c & 0x0f) << 12) | ((c1 & 0x3f) << 6)
|
||||||
| (c2 ^ 0x80);
|
| (c2 & 0x3f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue