0

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.

ScarletWitch
  • 522
  • 6
  • 23
  • You will observe that even SO has trimmed the backslash characters from your post. But Base64 will preserve backslashes, and does not itself generate backslashes, so the problem is not with Base64 encode/decode but rather with some step on either side. – Hot Licks Jun 26 '13 at 11:06
  • (Where did the backslashes come from???) – Hot Licks Jun 26 '13 at 11:13
  • 1
    sorry @HotLicks, But the Input string is exactly as shown. I editted it to show it this way. Thanks for the edit :) – ScarletWitch Jun 26 '13 at 12:26
  • Then use grave accent characters (to the left of "1" on your keyboard) around the string to show it without any characters being "adjusted" by SO's software. – Hot Licks Jun 26 '13 at 15:17
  • But you're still not making sense. Backslash characters do not belong in a URL. And Base64 does not use the backslash character. Where do the backslashes come from??? – Hot Licks Jun 26 '13 at 15:18
  • 1
    I dont know why are you implying that Base64 does not use backslashes. I have an mp3 file. which i encode in Base64 and on decoding that Base64 code, we are again getting an mp3 file. – ScarletWitch Jun 27 '13 at 06:52
  • If you base64-encode a binary file, the result is a sequence of ASCII characters not containing backslashes. I suspect, you are confusing something. The characters used in base64 are [A..Za..z0..9+/], a special "padding" character '=' and possibly CR+LF. There are variants, which deviate slightly using a different char for '+' and '/'. There are *various* RFCs describing the details. Be sure your base-64 decoder uses the same variant! – CouchDeveloper Jun 27 '13 at 08:38
  • @ScarletWitch If this question is related to your former question, you really don't need to base-64 encode the binary file. You send a binary file via a HTTP POST multipart/form-data request, which has a special form according [RFC 1867](http://www.ietf.org/rfc/rfc1867.txt) You can find more help via searching "HTTP File Upload" – CouchDeveloper Jun 27 '13 at 08:52
  • 1
    Thanks @CouchDeveloper . I will check out and try some other method. – ScarletWitch Jun 27 '13 at 09:11
  • I say Base64 does not use backslashes because [Base64 does not use backslashes](http://en.wikipedia.org/wiki/Base64). I'm sure it was a conscious decision, given that backslash is such a "problem child". Base64 *does* use forward slashes, and someone (outside of the Base64 encoder) may be inserting backslashes in a futile attempt to get URL processing to ignore the forward slashes, but that's the wrong way to go about it -- you should use URL encoding instead. – Hot Licks Jun 27 '13 at 10:51
  • (But you need to make clear what you mean by "sending data via URL request". Are you sending this data IN the URL of an HTTP request, or are you sending a block of data as a response to the request? Or are you actually sending a POST, which can contain blocks of data?) – Hot Licks Jun 27 '13 at 10:58

2 Answers2

0

If I understood you correctly, here's what you need:

\\/qwerty\\/\\/\\/qwertyuiop

More about the escaping characters you can read here:Wiki

torip3ng
  • 585
  • 2
  • 7
0

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 :

  1. URL encode an NSString
  2. 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)

Community
  • 1
  • 1
Bhavin
  • 27,155
  • 11
  • 55
  • 94