URL encoding

291 views
Skip to first unread message

Howard Nager

unread,
Oct 17, 2008, 7:28:59 PM10/17/08
to iphonesdkd...@googlegroups.com
Is there a simple way to encode a string so that the spaces, slashes,
etc are suitable for use as a url? I am looking to post some values to
my server, however they often contain spaces.

Ramin Firoozye

unread,
Oct 17, 2008, 7:35:31 PM10/17/08
to iphonesdkd...@googlegroups.com
+ [NSString stringByAddingPercentEscapesUsingEncoding];

or

CFURLCreateStringByAddingPercentEscapes

Ramin Firoozye

unread,
Oct 17, 2008, 7:40:16 PM10/17/08
to iphonesdkd...@googlegroups.com
Crap. Hit 'send' in mid-edit. The proper syntax is:

NSString* escapedUrl = [originalUrl
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

On Oct 17, 2008, at 4:28 PM, Howard Nager wrote:

Howard Nager

unread,
Oct 17, 2008, 8:16:03 PM10/17/08
to iphonesdkd...@googlegroups.com
Perfect - that did it!
Reply all
Reply to author
Forward
0 new messages