View Full Version : Creating a Url Compatible String
Mar 6, 2009, 04:26 PM
How can i transform a string that contains a url string to a url compatible string? i.e. place all the necessary % symbol, etc. I believe that in java it's encodeURLComponent and in php its urlencode. Is there a similar function on the iPhone?
Mar 6, 2009, 04:47 PM
There is an instance method in NSString that holds the answer.
Mar 6, 2009, 05:39 PM
I tried to use stringByAddingPercentEscapesUsingEncoding: but it doesn't do the job.
This my problem. I am downloading a file using a url and a urlrequest.
The url contains web auth in the format http://user:firstname.lastname@example.org .
The problem is that users with special characters in their password can't download the data. If they have a / symbol or % or @, etc they get a bad url error message. It's pretty important i release a fix fast for this. Please help.
Mar 6, 2009, 05:49 PM
Perhaps you need to consider using CFURLCreateStringByAddingPercentEscapes. Or maybe find a way to percent-escape those characters in the password that are valid URL characters beforehand.