mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Initial, untested implementation of stringByRemovingPercentEncoding.
This commit is contained in:
parent
fc13419877
commit
574fc45c0b
1 changed files with 30 additions and 1 deletions
|
@ -276,6 +276,14 @@ GSPathHandling(const char *mode)
|
|||
}
|
||||
}
|
||||
|
||||
inline int ishex(int x)
|
||||
{
|
||||
return
|
||||
(x >= '0' && x <= '9') ||
|
||||
(x >= 'a' && x <= 'f') ||
|
||||
(x >= 'A' && x <= 'F');
|
||||
}
|
||||
|
||||
#define GSPathHandlingRight() \
|
||||
((pathHandling == PH_DO_THE_RIGHT_THING) ? YES : NO)
|
||||
#define GSPathHandlingUnix() \
|
||||
|
@ -1930,7 +1938,28 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
|||
|
||||
- (NSString *) stringByRemovingPercentEncoding
|
||||
{
|
||||
return nil;
|
||||
NSData *data = [self dataUsingEncoding: NSUTF8StringEncoding];
|
||||
char *s = (char *)[data bytes];
|
||||
char *o;
|
||||
const char *end = s + strlen(s);
|
||||
int c;
|
||||
|
||||
for (o = 0; s <= end; o++) {
|
||||
c = *s++;
|
||||
if (c == '+')
|
||||
{
|
||||
c = ' ';
|
||||
}
|
||||
else if (c == '%' &&
|
||||
(!ishex(*s++) ||
|
||||
!ishex(*s++) ||
|
||||
!sscanf(s - 2, "%2x", &c)))
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
return [NSString stringWithCString: o encoding: NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue