You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let resBlob = new Blob([arraybuffer]) //res为arraybuffer型数据
let reader = new FileReader()
reader.readAsText(resBlob, "utf-8")
reader.onload = () => {
let tmpResObj = JSON.parse(reader.result)
}
functionab2str(buf){returnString.fromCharCode.apply(null,newUint16Array(buf));}functionstr2ab(str){varbuf=newArrayBuffer(str.length*2);// 2 bytes for each charvarbufView=newUint16Array(buf);for(vari=0,strLen=str.length;i<strLen;i++){bufView[i]=str.charCodeAt(i);}returnbuf;}
Activity
yuhaihe commentedon Jan 22, 2021
let resBlob = new Blob([arraybuffer]) //res为arraybuffer型数据
let reader = new FileReader()
reader.readAsText(resBlob, "utf-8")
reader.onload = () => {
let tmpResObj = JSON.parse(reader.result)
}
NoBey commentedon Mar 12, 2022
https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String