Convert ArrayBuffer to and from String - Node.js Data Type

Node.js examples for Data Type:Uint16Array

Description

Convert ArrayBuffer to and from String

Demo Code


'use strict';/*from  w  w w. j  a  v  a  2s.  c o  m*/

/**
 * @credit https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String?hl=en
 */
function arrayBufferToString(buffer) {
  return String.fromCharCode.apply(null, new Uint16Array(buffer));
}

Related Tutorials