Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
29
rated 0 times [  31] [ 2]  / answers: 1 / hits: 33068  / 12 Years ago, sun, april 22, 2012, 12:00:00

I was wondering...



(except the issue with the base64's plus'+' sign in query string - which is translated to 'space' and can be solved by %2b) :---> which is the preferred way to transfer data in query string?



Both functions can be used through the JS commands:




  • btoa

  • encodeUriComponent



so im asking myself(and you) :



when should I use what ? ( ive always used encodeUriCompoonent - by instinct).



the problem that the definitions are different - but the implementations can be similar...



edit



I think ive found the reason for asking.... ( and why nobody asked it before)



enter


More From » asp.net

 Answers
41

base64 is used to transfer binary data. (not supported in IE, cant encode spacial chars.)



encodeURIComponent only encodes special characters.



An interesting thing is that you can't apply base64 to unicode strings without encodeURIComponent:
https://developer.mozilla.org/en/DOM/window.btoa


[#86075] Friday, April 20, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
makaylahk

Total Points: 166
Total Questions: 94
Total Answers: 117

Location: Gabon
Member since Sat, Jul 25, 2020
4 Years ago
;