Skip to content

Instantly share code, notes, and snippets.

@inhji
Created September 22, 2014 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inhji/978f40e7e0a67b99b1ce to your computer and use it in GitHub Desktop.
Save inhji/978f40e7e0a67b99b1ce to your computer and use it in GitHub Desktop.
AtoBtoA.js
//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