Created
April 28, 2011 06:42
-
-
Save koichik/945919 to your computer and use it in GitHub Desktop.
Fix SlowBuffer.write() with 'ucs2' throws ReferenceError.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From c2c1bce691f0d6ec39f61b93ec9beb62ba3b08c9 Mon Sep 17 00:00:00 2001 | |
| From: koichik <koichik@improvement.jp> | |
| Date: Thu, 28 Apr 2011 15:38:28 +0900 | |
| Subject: [PATCH] Fix SlowBuffer.write() with 'ucs2' throws ReferenceError. | |
| --- | |
| lib/buffer.js | 2 +- | |
| test/simple/test-buffer.js | 5 +++++ | |
| 2 files changed, 6 insertions(+), 1 deletions(-) | |
| diff --git a/lib/buffer.js b/lib/buffer.js | |
| index ba0ae26..52e5e80 100644 | |
| --- a/lib/buffer.js | |
| +++ b/lib/buffer.js | |
| @@ -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'); | |
| diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js | |
| index 0edb642..11bc58b 100644 | |
| --- a/test/simple/test-buffer.js | |
| +++ b/test/simple/test-buffer.js | |
| @@ -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'), 'あいうえお'); | |
| -- | |
| 1.7.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment