From 296e84b4cf8a61ead37ee183aaddf1c0bb490a9d Mon Sep 17 00:00:00 2001 From: Holly Date: Tue, 26 Nov 2024 15:22:51 +0000 Subject: [PATCH] 1.7.1 --- base/WriterBase.ts | 1 + package-lock.json | 4 ++-- package.json | 2 +- writers/WriterBE.ts | 11 +++++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/base/WriterBase.ts b/base/WriterBase.ts index 43e1cd4..ffad28f 100644 --- a/base/WriterBase.ts +++ b/base/WriterBase.ts @@ -32,6 +32,7 @@ export class WriterBase { public writeBuffer(buffer:Buffer) { this.buffer = getBufferClass().concat([this.buffer, buffer], this.buffer.length + buffer.length); + this.offset += buffer.length; return this; } diff --git a/package-lock.json b/package-lock.json index 011aa85..79764b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bufferstuff", - "version": "1.7.0", + "version": "1.7.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bufferstuff", - "version": "1.7.0", + "version": "1.7.1", "license": "MIT", "devDependencies": { "check-outdated": "^2.12.0", diff --git a/package.json b/package.json index 131dfd2..587eb81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bufferstuff", - "version": "1.7.0", + "version": "1.7.1", "description": "A set of utility classes for reading and writing binary data in NodeJS and the browser", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/writers/WriterBE.ts b/writers/WriterBE.ts index ee8f760..b039241 100644 --- a/writers/WriterBE.ts +++ b/writers/WriterBE.ts @@ -174,18 +174,21 @@ export class WriterBE extends WriterBase implements IWriter { } public writeJavaUTF(text: string) { - this.writeUShort(text.length); + const dataWriter = new WriterBE(); for (let i = 0; i < text.length; i++) { const val = text.charCodeAt(i); if (val === 0) { - this.writeByte(0xC0); - this.writeByte(0X80); + dataWriter.writeByte(0xC0); + dataWriter.writeByte(0X80); } else { - this.writeByte(val); + dataWriter.writeByte(val); } } + this.writeUShort(text.length); + this.writeBuffer(dataWriter.toBuffer()); + return this; } } \ No newline at end of file