Created
September 22, 2014 12:58
-
-
Save inhji/978f40e7e0a67b99b1ce to your computer and use it in GitHub Desktop.
AtoBtoA.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://stackoverflow.com/questions/9786508/javascript-atob-returning-string-contains-an-invalid-character/9786592#9786592 | |
function utf8_to_b64( str ) { | |
return window.btoa(unescape(encodeURIComponent( str ))); | |
} | |
function b64_to_utf8( str ) { | |
return decodeURIComponent(escape(window.atob( str.replace(/\s/g, '') ))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment