SOURCE

function utf8_to_b64(str) {
    return window.btoa(unescape(encodeURIComponent(str)));
}

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

const log = console.log;

log(utf8_to_b64('✓ à la mode'));
log(b64_to_utf8('4pyTIMOgIGxhIG1vZGU='));
console 命令行工具 X clear

                    
>
console