Re: Using arguments in an NSURL...
Re: Using arguments in an NSURL...
- Subject: Re: Using arguments in an NSURL...
- From: "Dr. H. Nikolaus Schaller" <email@hidden>
- Date: Sat, 22 Mar 2003 14:40:03 +0100
Am Samstag, 22.03.03 um 08:15 Uhr schrieb Ryan robertson:
I'm using the NSURL initWithScheme initializer to create an NSURL. The
scheme and host are simple enough. The path however includes various
URL arguments (ie: "/login.html?name=ryan"). When I create the NSURL
object, all of the argument characters are escaped as the documentation
states they will be. Is there any way to disable this or to escape URL
argument characters (&, =, %) so that NSURL doesn't change them?
Thanks in advance...
Ryan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
Ryan,
I have used something like
- (NSString *) encodeAsURL;
{ // handle URL escapes
NSMutableString *url=[[self mutableCopy] autorelease];
[url replaceOccurrencesOfString:@"%" withString:@"%" options:0
range:NSMakeRange(0, [url length])];
[url replaceOccurrencesOfString:@" " withString:@" " options:0
range:NSMakeRange(0, [url length])];
[url replaceOccurrencesOfString:@":" withString:@":" options:0
range:NSMakeRange(0, [url length])];
[url replaceOccurrencesOfString:@"/" withString:@"/" options:0
range:NSMakeRange(0, [url length])];
[url replaceOccurrencesOfString:@";" withString:@";" options:0
range:NSMakeRange(0, [url length])];
[url replaceOccurrencesOfString:@"@" withString:@"@" options:0
range:NSMakeRange(0, [url length])];
return url;
}
But note, that this may be used only in the suffix part after the '?'
so you have to use [NSString stringWithFormat:@"/login.html?%@"
[@"name=ryan" encodeAsURL]];
Regards,
hns
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.