// 中文 base64 编码 function utf8_to_b64(str) { return window.btoa(unescape(encodeURIComponent(str))); } // 中文 base64 解码 function b64_to_utf8(str) { return decodeURIComponent(escape(window.atob(str))); }
非中文的话直接用 btoa 和 atob 就行了