function byteLength(string, encoding) {
+ if (string instanceof Buffer)
+ return string.length;
+
if (typeof string !== 'string')
string = '' + string;
assert.equal(Buffer.byteLength({}, 'raws'), 15);
assert.equal(Buffer.byteLength(), 9);
+// buffer
+var incomplete = new Buffer([0xe4, 0xb8, 0xad, 0xe6, 0x96]);
+assert.equal(Buffer.byteLength(incomplete), 5);
+var ascii = new Buffer('abc');
+assert.equal(Buffer.byteLength(ascii), 3);
+
// special case: zero length string
assert.equal(Buffer.byteLength('', 'ascii'), 0);
assert.equal(Buffer.byteLength('', 'HeX'), 0);