ArrayBuffer转换成字符串中文乱码问题

Posted justinwxt

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ArrayBuffer转换成字符串中文乱码问题相关的知识,希望对你有一定的参考价值。

  buf2str(buffer) {
      
      let  encodedString = String.fromCodePoint.apply(null, new Uint8Array(buffer));
      let decodedString = decodeURIComponent(escape(encodedString));//没有这一步中文会乱码
      console.log(decodedString);
      return decodedString
    },

  时间紧迫,请看代码。亲测有效

以上是关于ArrayBuffer转换成字符串中文乱码问题的主要内容,如果未能解决你的问题,请参考以下文章