arraybuffer转字符串如何解决中文乱码问题?

发布于 7 年前作者 zengwei6020 次浏览最后编辑 7 年前来自 issues
 this.data.socket = wx.createUDPSocket()
       this.data.socket.onMessage(function(res){
          console.log(res)
          var unit8Array = new Uint8Array(res['message'])
          let encodeString = String.fromCharCode.apply(null, unit8Array)
          encodeString = encodeString.replace(/%/g,'%25')
          var data = decodeURIComponent(escape(encodeString))
          console.log('接收到:',data)
    })
1 回复
yang37
yang371 楼5 年前

如果不加decodeURIComponent 就乱码 加了报错URI malformed URIError: URI malformed 有大佬知道怎么解决吗