Skip to content

Instantly share code, notes, and snippets.

@Neoglyph
Created September 19, 2017 22:09
Show Gist options
  • Save Neoglyph/772f2630bbb21ae446b02659d5b82a49 to your computer and use it in GitHub Desktop.
Save Neoglyph/772f2630bbb21ae446b02659d5b82a49 to your computer and use it in GitHub Desktop.
UTF-8 base64 decode
// base64 decode and utf-8 decode the base64 encoded string
let encodedData = 'base64encodedstring...';
let decodedData = JSON.parse(decodeURIComponent(Array.prototype.map.call(atob(encodedData), function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join('')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment