mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fix issue with character set caching.
This commit is contained in:
parent
51e0e3f45e
commit
f1b48541ae
3 changed files with 84 additions and 8 deletions
|
@ -841,44 +841,48 @@ static Class concreteMutableClass = nil;
|
|||
|
||||
+ (id) URLFragmentAllowedCharacterSet;
|
||||
{
|
||||
// NSString *charSetString = @"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?/:@-._~!$&'()*+,=";
|
||||
// NSData *data = [charSetString dataUsingEncoding: NSUTF8StringEncoding];
|
||||
// char *bytes = [data bytes];
|
||||
|
||||
return [self _staticSet: urlFragmentAllowedCharSet
|
||||
length: sizeof(urlFragmentAllowedCharSet)
|
||||
number: 0];
|
||||
number: 15];
|
||||
}
|
||||
|
||||
+ (id) URLPasswordAllowedCharacterSet;
|
||||
{
|
||||
return [self _staticSet: urlPasswordAllowedCharSet
|
||||
length: sizeof(urlPasswordAllowedCharSet)
|
||||
number: 0];
|
||||
number: 16];
|
||||
}
|
||||
|
||||
+ (id) URLPathAllowedCharacterSet;
|
||||
{
|
||||
return [self _staticSet: urlPathAllowedCharSet
|
||||
length: sizeof(urlPathAllowedCharSet)
|
||||
number: 0];
|
||||
number: 17];
|
||||
}
|
||||
|
||||
+ (id) URLQueryAllowedCharacterSet;
|
||||
{
|
||||
return [self _staticSet: urlQueryAllowedCharSet
|
||||
length: sizeof(urlQueryAllowedCharSet)
|
||||
number: 0];
|
||||
number: 18];
|
||||
}
|
||||
|
||||
+ (id) URLUserAllowedCharacterSet
|
||||
{
|
||||
return [self _staticSet: urlUserAllowedCharSet
|
||||
length: sizeof(urlUserAllowedCharSet)
|
||||
number: 0];
|
||||
number: 19];
|
||||
}
|
||||
|
||||
+ (id) URLHostAllowedCharacterSet
|
||||
{
|
||||
return [self _staticSet: urlHostAllowedCharSet
|
||||
length: sizeof(urlHostAllowedCharSet)
|
||||
number: 0];
|
||||
number: 20];
|
||||
}
|
||||
|
||||
- (NSData*) bitmapRepresentation
|
||||
|
@ -1166,6 +1170,36 @@ static Class concreteMutableClass = nil;
|
|||
return AUTORELEASE([[abstractClass performSelector: _cmd] mutableCopy]);
|
||||
}
|
||||
|
||||
+ (id) URLFragmentAllowedCharacterSet;
|
||||
{
|
||||
return AUTORELEASE([[abstractClass performSelector: _cmd] mutableCopy]);
|
||||
}
|
||||
|
||||
+ (id) URLHostAllowedCharacterSet;
|
||||
{
|
||||
return AUTORELEASE([[abstractClass performSelector: _cmd] mutableCopy]);
|
||||
}
|
||||
|
||||
+ (id) URLPasswordAllowedCharacterSet;
|
||||
{
|
||||
return AUTORELEASE([[abstractClass performSelector: _cmd] mutableCopy]);
|
||||
}
|
||||
|
||||
+ (id) URLPathAllowedCharacterSet;
|
||||
{
|
||||
return AUTORELEASE([[abstractClass performSelector: _cmd] mutableCopy]);
|
||||
}
|
||||
|
||||
+ (id) URLQueryAllowedCharacterSet;
|
||||
{
|
||||
return AUTORELEASE([[abstractClass performSelector: _cmd] mutableCopy]);
|
||||
}
|
||||
|
||||
+ (id) URLUserAllowedCharacterSet
|
||||
{
|
||||
return AUTORELEASE([[abstractClass performSelector: _cmd] mutableCopy]);
|
||||
}
|
||||
|
||||
+ (id) characterSetWithCharactersInString: (NSString*)aString
|
||||
{
|
||||
NSMutableCharacterSet *ms;
|
||||
|
|
|
@ -88,8 +88,49 @@ int main()
|
|||
![theSet characterIsMember: '#'],
|
||||
"Check custom set");
|
||||
|
||||
|
||||
|
||||
theSet = [NSCharacterSet URLFragmentAllowedCharacterSet];
|
||||
NSString *setString = @"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?/:@-._~!$&'()*+,=";
|
||||
NSUInteger i = 0;
|
||||
for(i = 0; i < [setString length]; i++)
|
||||
{
|
||||
char c = [setString characterAtIndex: i];
|
||||
if([theSet characterIsMember: c] == NO) // , [msg cStringUsingEncoding: NSUTF8Encoding]);
|
||||
{
|
||||
NSLog(@"%c is not in set", c);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Success");
|
||||
}
|
||||
}
|
||||
/*
|
||||
PASS(//[theSet characterIsMember: 'A'] &&
|
||||
//[theSet characterIsMember: 'Z'] &&
|
||||
//[theSet characterIsMember: 'a'] &&
|
||||
//[theSet characterIsMember: 'z'] &&
|
||||
//[theSet characterIsMember: '9'] &&
|
||||
// [theSet characterIsMember: '0'] &&
|
||||
[theSet characterIsMember: '?'] &&
|
||||
[theSet characterIsMember: '/ '] &&
|
||||
[theSet characterIsMember: ':'] &&
|
||||
[theSet characterIsMember: '@ '] &&
|
||||
[theSet characterIsMember: '-'] &&
|
||||
[theSet characterIsMember: '.'] &&
|
||||
[theSet characterIsMember: '_'] &&
|
||||
[theSet characterIsMember: '~'] &&
|
||||
[theSet characterIsMember: '!'] &&
|
||||
[theSet characterIsMember: '$ '] &&
|
||||
[theSet characterIsMember: '&'] &&
|
||||
// [theSet characterIsMember: '\''] &&
|
||||
[theSet characterIsMember: '('] &&
|
||||
[theSet characterIsMember: ')'] &&
|
||||
[theSet characterIsMember: '*'] &&
|
||||
[theSet characterIsMember: '+'] &&
|
||||
[theSet characterIsMember: ','] &&
|
||||
[theSet characterIsMember: ';'] &&
|
||||
[theSet characterIsMember: '='],
|
||||
"Check some characters from URLFramgmentAllowedCharacterSet"); */
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ int main (int argc, const char * argv[])
|
|||
allowedCharacterSet = [[NSCharacterSet alphanumericCharacterSet] invertedSet];
|
||||
PASS(testUrlCharacterSetEncoding(urlDecodedString, urlEncodedString, allowedCharacterSet), "inverted");
|
||||
|
||||
// NSLog(@"Test4");
|
||||
// urlDecodedString = @"Here are some Emojis: \U0001F601 \U0001F602 \U0001F638 Emojis done."; // Multibyte encoded characters
|
||||
// urlEncodedString = @"Here%20are%20some%20Emojis:%20%F0%9F%98%81%20%F0%9F%98%82%20%F0%9F%98%B8%20Emojis%20done.";
|
||||
// allowedCharacterSet = [NSCharacterSet URLFragmentAllowedCharacterSet];
|
||||
|
|
Loading…
Reference in a new issue