var buf1 = new Buffer(100);
var buf2 = new Buffer([0,1,2]);
var buf3 = new Buffer(‘hello world‘,‘utf8‘);
var buffer = new Buffer(‘node‘,‘utf8‘);
var str = buffer.toString(‘utf8‘);
var buffer = new Buffer(‘node‘);
var json = JSON.stringify(buffer);
var copy = new Buffer(JSON.parse(json));
copy.toString();
Buffer.isBuffer(obj); //检查是否buffer
Buffer.byteLength(string,[encoding]); //计算指定字符串的字节数
Buffer.concat(list,[totalLength]); //将几个Buffer对象结合成一个新的Buffer对象
Buffer.isEncoding(encoding); //检查是否为有效的编码格式
原文:http://www.cnblogs.com/SLchuck/p/4909264.html