String from UTF8 Byte Array - Node.js String

Node.js examples for String:Unicode

Description

String from UTF8 Byte Array

Demo Code


if (typeof String.prototype.fromUTF8ByteArray != 'function')
String.fromUTF8ByteArray = function(arr, offset, length)
{
  var str = "";
  if (typeof(offset) == "undefined")
  {//from   w w w .jav a2  s  .c o  m
    offset = 0; length = arr.length;
  }
  
  for (var i=offset; i<length; i++)
    str += String.fromCharCode(arr[i]);
  
  return String.utf8Decode(str);
};

Related Tutorials