Fix SlowBuffer.write() with 'ucs2' throws ReferenceError.
authorkoichik <koichik@improvement.jp>
Thu, 28 Apr 2011 06:38:28 +0000 (15:38 +0900)
committerRyan Dahl <ry@tinyclouds.org>
Thu, 28 Apr 2011 08:57:00 +0000 (04:57 -0400)
lib/buffer.js
test/simple/test-buffer.js

index ba0ae26..52e5e80 100644 (file)
@@ -100,7 +100,7 @@ SlowBuffer.prototype.write = function(string, offset, encoding) {
 
     case 'ucs2':
     case 'ucs-2':
-      return this.ucs2Write(start, end);
+      return this.ucs2Write(string, offset);
 
     default:
       throw new Error('Unknown encoding');
index 0edb642..11bc58b 100644 (file)
@@ -500,3 +500,8 @@ console.log(z.length)
 assert.equal(2, z.length);
 assert.equal(0x66, z[0]);
 assert.equal(0x6f, z[1]);
+
+
+var b = new SlowBuffer(10);
+b.write('あいうえお', 'ucs2');
+assert.equal(b.toString('ucs2'), 'あいうえお');