arraybuffer转字符串如何解决中文乱码问题?
发布于 5 年前 作者 zengwei 5861 次浏览 来自 官方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 回复

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



回到顶部