Does stringbyadding percentescapes usingencoding work?

Discussion in 'iPhone/iPad Programming' started by fenrus110, Nov 27, 2008.

  1. macrumors regular

    Joined:
    Mar 24, 2008
    #1
    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.
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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?
     
  3. thread starter macrumors regular

    Joined:
    Mar 24, 2008
    #3
    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.
     
  4. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    You probably want to start looking into NSXMLParser then.

    Also look into maybe using CFURLCreateStringByAddingPercentEscapes.
     

Share This Page