Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

fenrus110

macrumors regular
Original poster
Mar 24, 2008
142
0
I searched a few threads about it and people said it worked. I tried both NSASCIIStringEncoding and NSUTF8StringEncoding. I NSLogged it and it appears to escape spaces with %20, but it doesn't escape any other characters.

and for the record, I have always passed stuff like the @ and < symbols fine without escape. But the main problem is with the & character, because that is a symbol for a POST parameter.

And that above method doesn't escape it, only the spaces.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
stringByAddingPercentEscapesUsingEncoding:
Returns a representation of the receiver using a given encoding to determine the percent escapes necessary to convert the receiver into a legal URL string.

In a legal URL string, &'s don't need to be encoded. What are you trying to do with this string once you have it encoded?
 

fenrus110

macrumors regular
Original poster
Mar 24, 2008
142
0
well I'm just trying to post stuff from a UITextView onto a server. Works fine and dandy, except when I run into characters like & and <

Haven't totally ironed out the details, but I do know that getting back the data is a problem, because when I need to get the data back, it's in XML format.

I guess I could manually do a character replace with the string replace functions.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
well I'm just trying to post stuff from a UITextView onto a server. Works fine and dandy, except when I run into characters like & and <

Haven't totally ironed out the details, but I do know that getting back the data is a problem, because when I need to get the data back, it's in XML format.
You probably want to start looking into NSXMLParser then.

I guess I could manually do a character replace with the string replace functions.
Also look into maybe using CFURLCreateStringByAddingPercentEscapes.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.