响应的html用的是gbk编码,里面的中文是乱码,请问怎么解决

阅读次数 101

代码中为:

let html = resp.text();
console.log(html)

打印内容包含了如下中文乱码: image.png

希望能读取乱码内容,应该如何解决。即使将乱码输出为base64或url编码也可以。

我测试过用这个提问中的stringToGBK函数,依旧不行 https://airsheet-community.wps.cn/questions/10010000000000675

1 Answers
const resp = HTTP.get(xxxx)
const body = resp.binary()
const base64 = body.toString("base64") 

可以通过这种方式解决