From 77ea7c1798015f1b55fe4788b99f47128ed2c294 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Tue, 8 Jun 2021 12:50:41 +0530 Subject: [PATCH] string encoding bug fix --- src/Binary/Encoder.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Binary/Encoder.ts b/src/Binary/Encoder.ts index 2b8ea6e..63331e9 100644 --- a/src/Binary/Encoder.ts +++ b/src/Binary/Encoder.ts @@ -18,11 +18,6 @@ export default class Encoder { } pushBytes(bytes: Uint8Array | Buffer | number[]) { bytes.forEach (b => this.data.push(b)) - //this.data.push.apply(this.data, bytes) - } - pushString(str: string) { - const bytes = Buffer.from (str, 'utf-8') - this.pushBytes(bytes) } writeByteLength(length: number) { if (length >= 4294967296) throw new Error('string too large to encode: ' + length) @@ -39,8 +34,9 @@ export default class Encoder { } } writeStringRaw(string: string) { - this.writeByteLength(string.length) - this.pushString(string) + const bytes = Buffer.from (string, 'utf-8') + this.writeByteLength(bytes.length) + this.pushBytes(bytes) } writeJid(left: string, right: string) { this.pushByte(WA.Tags.JID_PAIR)