mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Correct implementation of method.
This commit is contained in:
parent
9e960dfcd2
commit
fc13419877
1 changed files with 12 additions and 18 deletions
|
@ -1902,31 +1902,25 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
|||
dst = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), slen * 3);
|
||||
while (spos < slen)
|
||||
{
|
||||
unsigned char c = src[spos++];
|
||||
unichar c = src[spos++];
|
||||
unsigned int hi;
|
||||
unsigned int lo;
|
||||
|
||||
if([aSet characterIsMember: c])
|
||||
if([aSet characterIsMember: c]) // if the character is in the allowed set, put it in
|
||||
{
|
||||
|
||||
if (c <= 32 || c > 126 || c == 34 || c == 35 || c == 37
|
||||
|| c == 60 || c == 62 || c == 91 || c == 92 || c == 93
|
||||
|| c == 94 || c == 96 || c == 123 || c == 124 || c == 125)
|
||||
{
|
||||
dst[dpos++] = '%';
|
||||
hi = (c & 0xf0) >> 4;
|
||||
dst[dpos++] = (hi > 9) ? 'A' + hi - 10 : '0' + hi;
|
||||
lo = (c & 0x0f);
|
||||
dst[dpos++] = (lo > 9) ? 'A' + lo - 10 : '0' + lo;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst[dpos++] = c;
|
||||
}
|
||||
dst[dpos++] = c;
|
||||
}
|
||||
else // if not, then encode it...
|
||||
{
|
||||
dst[dpos++] = '%';
|
||||
hi = (c & 0xf0) >> 4;
|
||||
dst[dpos++] = (hi > 9) ? 'A' + hi - 10 : '0' + hi;
|
||||
lo = (c & 0x0f);
|
||||
dst[dpos++] = (lo > 9) ? 'A' + lo - 10 : '0' + lo;
|
||||
}
|
||||
s = [[NSString alloc] initWithBytes: dst
|
||||
length: dpos
|
||||
encoding: NSASCIIStringEncoding];
|
||||
encoding: NSUTF8StringEncoding];
|
||||
NSZoneFree(NSDefaultMallocZone(), dst);
|
||||
IF_NO_GC([s autorelease];)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue