diff --git a/HISTORY.md b/HISTORY.md index c5b022c7..8945b324 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,9 @@ === * Drop support for Node.js 0.8 + * deps: iconv-lite@0.5.2 + - Add encoding cp720 + - Add encoding UTF-32 2.5.2 / 2023-02-21 ================== diff --git a/package.json b/package.json index aabb1c36..5429a8cf 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", - "iconv-lite": "0.4.24", + "iconv-lite": "0.5.2", "unpipe": "1.0.0" }, "devDependencies": { diff --git a/test/index.js b/test/index.js index de1fc904..856158d7 100644 --- a/test/index.js +++ b/test/index.js @@ -398,6 +398,28 @@ describe('Raw Body', function () { }) }) + it('should decode UTF-32 string (LE BOM)', function (done) { + // BOM makes this LE + var stream = createStream(Buffer.from('fffe0000bf00000043000000f30000006d0000006f00000020000000650000007300000074000000e1000000730000003f000000', 'hex')) + var string = '¿Cómo estás?' + getRawBody(stream, 'utf-32', function (err, str) { + assert.ifError(err) + assert.strictEqual(str, string) + done() + }) + }) + + it('should decode UTF-32 string (BE BOM)', function (done) { + // BOM makes this BE + var stream = createStream(Buffer.from('0000feff000000bf00000043000000f30000006d0000006f00000020000000650000007300000074000000e1000000730000003f', 'hex')) + var string = '¿Cómo estás?' + getRawBody(stream, 'utf-32', function (err, str) { + assert.ifError(err) + assert.strictEqual(str, string) + done() + }) + }) + it('should correctly calculate the expected length', function (done) { var stream = createStream(Buffer.from('{"test":"å"}'))