使用小程序的中wx.request()請(qǐng)求chatGpt流式接口的實(shí)現(xiàn)
可以成功接收到數(shù)據(jù),但是遇到了下面的問(wèn)題,就是在接收的數(shù)據(jù)如果是中文會(huì)出現(xiàn)亂碼,英文沒(méi)有問(wèn)題,可以正常解析出來(lái)。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-662460.html
大家有遇到這個(gè)問(wèn)題嗎,求解,求解…文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-662460.html
const requestTask = wx.request({
url: 'url',
enableChunked: true,
header: {
'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
}
})
requestTask.onChunkReceived(response => {
const arrayBuffer = response.data;
let unit8Arr = new Uint8Array(arrayBuffer)
let text = String.fromCharCode.apply(null, unit8Arr);
var str=new TextDecoder("utf-8").decode(unit8Arr)
//此處中文亂碼
console.log(str)
})
setTimeout(()=>{
requestTask.abort();
},2000)
到了這里,關(guān)于使用小程序的wx.request()請(qǐng)求chatGpt流式接口的實(shí)現(xiàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!