Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6213647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:44:02+00:00 2026-05-24T06:44:02+00:00

I am sending a post containing text, numbers and data. The numbers and data

  • 0

I am sending a post containing text, numbers and data. The numbers and data work fine, but I’m having problems with the text, since it may contain an ampersand (&). For example

page.php?text=Hello World & Space.

Now I found that the “&” is received by server, but read as if a new variable starts. So it sees (I think):

text = "Hello World "
Space. =

I did read that I could try to encode the text to make it look like it’s a URL (like ” ” [space] turns into “%20”) but there is no way to encode it properly. I came to the conclusion:

textToPOST = [text stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

But that does NOT encode the ampersands, but everything else. So the result is:

some text ü blablabla

turns into

some%20text%20ü%20blablabla

with the & not encoded. So how can I do this, please help.

Thanks a lot already

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:44:02+00:00Added an answer on May 24, 2026 at 6:44 am

    Thanks for that answer and sorry for my premature posting :S I hope it at least helps anybody who has the same issue as I had. I just had a chat with a friend and he told me:

    To display and ampersand in XML simply use the & quote. Unlike with a pure “&”, the NSXMLParser won’t output an error. Using & also allows you to make other symbol escapes like:

    • ü [in text] -> ü [in HTML] -> ü [in XML]
    • Ä [in text] -> Ä [in HTML] -> Ä [in XML]
    • ß [in text] -> ß [in HTML] -> ß [in XML]
    • etc…

    So that’s how you solve the “How do I parse XML with an amp in it problem“. Also I managed to make the code, from the website I linked in a comment to my original question, work:

    NSMutableString *deutschEscaped = [NSMutableString stringWithString:[[deutschTextLabel string] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    [deutschEscaped replaceOccurrencesOfString:@"$" withString:@"%24" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"&" withString:@"%26" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"+" withString:@"%2B" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"," withString:@"%2C" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"/" withString:@"%2F" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@":" withString:@"%3A" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@";" withString:@"%3B" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"=" withString:@"%3D" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"?" withString:@"%3F" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"@" withString:@"%40" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@" " withString:@"%20" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"\t" withString:@"%09" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"#" withString:@"%23" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"<" withString:@"%3C" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@">" withString:@"%3E" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"\"" withString:@"%22" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    [deutschEscaped replaceOccurrencesOfString:@"\n" withString:@"%0A" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [deutschEscaped length])];
    

    This works fine for me and does replace ampersands and any other possible hazards.

    If you don’t want many %20 escapes for every space, you can also use:

    NSMutableString *englishEscaped = [NSMutableString stringWithString:[[englishTextLabel string] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    

    Thank you all 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems with sending POST data to a PHP script with NSURLConnection.
I'm having problems with sending POST request in C# and it seems I misunderstood
When sending data via POST or GET with jQuery you use for format {
I'm looking into sending regular automated text-messages to a list of subscribed users. Having
Possible Duplicate: sending post data from Iphone Hello everyone, I'm a new member of
I'm struggling sending POST data to a server and receiving the correct response. I
I had a response on a question yesterday about sending POST data to the
I'm trying to refresh a page without sending POST from the previous time. I've
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
sending mail along with embedded image using asp.net I have already used following but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.