NNikN
NNikN

Reputation: 3852

Consider all characters for URL Encode, post data, complete solution iOS

I am sending the data to a server in post body. For which I had used the following code from the Encoding URL Data.

CFStringRef encodedString = CFURLCreateStringByAddingPercentEscapes(
    kCFAllocatorDefault,
    originalString,
    NULL,
    CFSTR(":/?#[]@!$&'()*+,;="),
    kCFStringEncodingUTF8);

Later on I forgot to add one more character in the list which was "’" , a apostrophe. I don't how many character's to add.

Also, if there are some special character's to be submitted to a server with application/x-www-form-urlencoded, what could be a best and stable solution.

Upvotes: 1

Views: 724

Answers (1)

Duck
Duck

Reputation: 36003

It appears that you are missing % on your string.

There is also another solution you can try:

NSString *encodedURL = [rawURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Upvotes: 1

Related Questions