Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range

发布时间 2023-08-21 12:09:09作者: w1ndz

在使用浏览器内置API btoa() 编码base64时:
报错Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range

报错信息解释:
报错信息中指出字符串中包含了Latin1范围之外的字符,导致无法使用window.btoa进行解析。根据你提供的字符串,我们可以看到其中包含了中文字符"区"和"桥",这些字符属于Unicode字符集,超出了Latin1范围。

为了解决这个问题,你可以使用其他方法或库来进行编码。比如js-base64即可