mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
string encoding bug fix
This commit is contained in:
@@ -18,11 +18,6 @@ export default class Encoder {
|
|||||||
}
|
}
|
||||||
pushBytes(bytes: Uint8Array | Buffer | number[]) {
|
pushBytes(bytes: Uint8Array | Buffer | number[]) {
|
||||||
bytes.forEach (b => this.data.push(b))
|
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) {
|
writeByteLength(length: number) {
|
||||||
if (length >= 4294967296) throw new Error('string too large to encode: ' + length)
|
if (length >= 4294967296) throw new Error('string too large to encode: ' + length)
|
||||||
@@ -39,8 +34,9 @@ export default class Encoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeStringRaw(string: string) {
|
writeStringRaw(string: string) {
|
||||||
this.writeByteLength(string.length)
|
const bytes = Buffer.from (string, 'utf-8')
|
||||||
this.pushString(string)
|
this.writeByteLength(bytes.length)
|
||||||
|
this.pushBytes(bytes)
|
||||||
}
|
}
|
||||||
writeJid(left: string, right: string) {
|
writeJid(left: string, right: string) {
|
||||||
this.pushByte(WA.Tags.JID_PAIR)
|
this.pushByte(WA.Tags.JID_PAIR)
|
||||||
|
|||||||
Reference in New Issue
Block a user