Node.js Buffer convert to String

Description

Node.js Buffer convert to String


let buf = Buffer.alloc(26);
buf[0] = 49;//from   w  w w  .java 2  s  .  c o m
for (var i = 1 ; i < 26 ; i++) {
  buf[i] = i + 97;
}

console.log( buf.toString('ascii'));      
console.log( buf.toString('ascii',0,5));
console.log( buf.toString('utf8',0,5));
console.log( buf.toString(undefined,0,5));



PreviousNext

Related