url-Encode vs Base64 encoding ( usages)?

前端 未结 3 624
心在旅途
心在旅途 2020-12-24 12:31

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) :---> w

3条回答
  •  北海茫月
    2020-12-24 13:01

    The answer to this is entirely dependent on your server-side application.

    '+' is not translated to 'space' by the client - it is auto-translated to 'space' by some server-side apps, largely for backward-compatibility reasons (conversely, some server-side apps will leave '+' as '+' in compliance with RFC3986 ).

    As far as the client is concerned - btoa() and encodeURIComponent() (and encodeURI() and escape()) just encode a string of text into different abstracted strings according to different encoding or escaping algorithms - btoa() usually produces the smallest resultant string using base64 encoding but meze's comment re: unicode is worth taking into account here.

    The important thing to note is what your server-side application (some ASP.NET-based setup in your case) then uses to decode that string back to it's original form.

提交回复
热议问题