Base64 encoding and decoding in client-side Javascript

前端 未结 14 2366
挽巷
挽巷 2020-11-22 04:27

Are there any methods in JavaScript that could be used to encode and decode a string using base64 encoding?

14条回答
  •  情书的邮戳
    2020-11-22 04:58

    function b64_to_utf8( str ) {
      return decodeURIComponent(escape(window.atob( str )));
    }

    https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_.22Unicode_Problem.22

提交回复
热议问题