JS中 atob 方法解码中文字符乱码问题
2023-11-22 本文已影响0人
yujiawei007
// 中文 base64 编码
function utf8_to_b64(str) {
return window.btoa(unescape(encodeURIComponent(str)));
}
// 中文 base64 解码
function b64_to_utf8(str) {
return decodeURIComponent(escape(window.atob(str)));
}