Convert an array of big-endian words to a string - Node.js String

Node.js examples for String:Big endian

Description

Convert an array of big-endian words to a string

Demo Code


var chrsz = 8;/*from   w  w w .j av  a  2  s .  c  o m*/

function binb2str(bin) {
  var str = "";
  var mask = (1 << chrsz) - 1;
  for (var i = 0; i < bin.length * 32; i += chrsz)
    str += String.fromCharCode((bin[i >> 5] >>> (32 - chrsz - i % 32)) & mask);
  return str;
}

Related Tutorials