Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Added: Dec 24, 2017 11:15 AM
Modified: Mar 15, 2019 11:07 AM
Views: 22
Tags: base64
  1. /**
  2.  * Base 64 decode text
  3.  * @var string str Base64 encoding text
  4.  */
  5. function b64DecodeUnicode(str) {
  6.     // Going backwards: from bytestream, to percent-encoding, to original string.
  7.     return decodeURIComponent(atob(str).split('').map(function(c) {
  8.         return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
  9.     }).join(''));
  10. }
  11.  
  12. b64DecodeUnicode('4pyTIMOgIGxhIG1vZGU='); // "✓ à la mode"