\ trimmed when sending data via NSURLRequest - iphone

I have a string which is a base64encoding of an audio file and looks like -"\/qwerty\/\/\/qwertyuiop". However, my server side developer says he just receives -"/qwerty///qwertyuiop". Which does not give the same result in decoding. So in what format do i send him that he will receive -"\/qwerty\/\/\/qwertyuiop" ? Please help.

I think what you want is to escape "\" from your URL. You can use BackSlash Escape Character.
Update :
You can use the Answer from these links :
URL encode an NSString
How do I do base64 encoding on iphone-sdk ?
Also take a look at this Beautiful Link : HTML URL Encoding Reference (Credit goes to HotLicks)

If I understood you correctly, here's what you need:
\\/qwerty\\/\\/\\/qwertyuiop
More about the escaping characters you can read here:Wiki

Related

Not able to pass special character into request

When I try to make request with some special character like japanese , then request is going to break and i am not able to get result. so my question is, how to pass special character in other language into request ?
Thanks in Advance.
You should encode your characters to UTF8 like this
NSString *encodedURL = [oldUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Blob data replace '+' with space

I have an iphone app that converts a image into NSData & then converts into base64 encoded string.
When this encoded string is submitted to server in server's database, while storing on server '+' gets converted into 'space' and so the decoder does not work properly.
I guess the issue is with default encoding of table in database. Currently its latin, i tried changing it to UTF8 but problem still exits.
Any other encoding, please help
Of course - that has nothing to do with encoding. It is the format of the POST and GET parameters which creates a clash with base64. In http://en.wikipedia.org/wiki/Base64#Variants_summary_table you see alternatives which are designed to make base64 work with URLs etc.
One of these variants is "Base64 with URL and Filename Safe Alphabet (RFC 4648 'base64url' encoding)" which replaces the + with - and the / with _.
Another alternative would be to replace the offending characters +/= by their respective hexrepresentations with %xx - but that makes the data unnecessarily longer.

json parsing in objective c

while parsing the content of a .json file, string like "jamie's" is represented as "jamie 's".Any one know why it is so?
Make sure you are using application/json as a content type to transfer the data from the server to the client.
You can also go through following link
http://mobile.tutsplus.com/tutorials/iphone/iphone-json-twitter-api/
because the apostrophe is a special charachter and cant be transmitted inside of http packets. all special characters must be replaced with escape sequences like ' or with percent escapes %27 ...
in the NSString class you will find the methods 'stringByReplacingPercentEscapesUsingEncoding:' and 'stringByAddingPercentEscapesUsingEncoding:' for handle percent escapes.
the escape sequencies you must handle by yourself for example with 'stringByReplacingOccurrencesOfString:#"##039;" withString:#"'"' ...

How to handle '&' in URL sent as HTML from iPhone Mail.app

Apologies if this has been answered already. There are similar topics but none that I could find pertaining to Cocoa & NSStrings...
I'm constructing a clickable URL to embed in an HTML email to be sent via the MFMailComposeViewController on the iPhone. i create the url then use stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding to polish up white space, etc. then add some surrounding HTML to get:
view
All's well so it's appended to emailBody. However once [mailComposer setMessageBody:emailBody isHTML:YES] all the & become & which isn't ideal within my URL.
can i control this? is there a better encoding algorithm? my HTML is a bit rusty perhaps I'm using the wrong encoding? I'm sure on the server I could parse the & back into & but looking for the Cocoa way...
Thanks!
Actually, & should always be encoded as & in HTML attributes. Including links. Including form value delimiters. So it's done exactly what you want, even though you didn't know you wanted it.
Look at it this way: in your URL, you have &age=53... That's interpreted first as a character entity, and only after that doesn't work is it interpreted as an ampersand followed by more character data.
The W3C spec is quite clear on this:
Authors should use "&" (ASCII decimal 38) instead of "&" to avoid confusion with the beginning of a character reference (entity reference open delimiter). Authors should also use "&" in attribute values since character references are allowed within CDATA attribute values.
That should settle it: use & not &.
Are you calling MFMailComposeViewController's
setMessageBody:isHTML:
and what do you set isHTML to?
Depending on it's setting it might very well be that MFMailComposeViewController is trying to help you out be encoding the entire message body...
Either don't encode the body yourself or make the entire body HTML.

What kind of text code is %62%69%73%68%6F%70?

On a specific webpage, when I hover over a link, I can see the text as "bishop" but when I copy-and-paste the link to TextPad, it shows up as "%62%69%73%68%6F%70". What kind of code is this, and how can I convert it into text?
Thanks!
URL encoding, I think.
You can decode it here: http://meyerweb.com/eric/tools/dencoder/
Most programming languages will have functions to urlencode/decode too.
This is URL encoding. It is designed to pass characters like < / or & through a URL using their ASCII values in hex after a %. However, you can also use this for characters that don't need encoding per se. Makes the URL harder to read, which is sometimes desirable.
URL encoding replaces characters outside the ascii set.
More info about URL encoding in the w3schools site.
As mentioned by others, this is simply an ASCII representation of the text so that it can be passed around the HTTP object easily. If you've ever noticed typing in a website URL that has a space in it, the browser will usually convert that to %20. That's the hexadecimal value for the "space" character in ASCII.
This used to be a way to trick old spam scrapers. One way spammers get email addresses is to scrape the source code of websites for strings matching the pattern "username#company.tld". By encoding just the username portion or the whole string as ASCII characters, the string would be readable by humans, but would require the scraper to convert it to a literal string before it could be used to send emails. Of course, modern-day spamming tools account for these sort of strings.