Converting between strings and ArrayBuffers

后端 未结 24 844
慢半拍i
慢半拍i 2020-11-22 04:50

Is there a commonly accepted technique for efficiently converting JavaScript strings to ArrayBuffers and vice-versa? Specifically, I\'d like to be able to write the contents

24条回答
  •  囚心锁ツ
    2020-11-22 05:24

    var decoder = new TextDecoder ();
    var string = decoder.decode (arrayBuffer);
    

    See https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/decode

提交回复
热议问题