strings obey lang
This commit is contained in:
parent
9ae7e46855
commit
c8cba3c45e
|
@ -335,8 +335,9 @@ export class Bert {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
decode_string = (buffer) => {
|
decode_string = (buffer) => {
|
||||||
const size = this.bytesToInt(buffer, 2, true);
|
const sizeLen = this.convention == Lang.ELIXIR ? 4 : 2;
|
||||||
buffer = buffer.subarray(2);
|
const size = this.bytesToInt(buffer, sizeLen, true);
|
||||||
|
buffer = buffer.subarray(sizeLen);
|
||||||
return {
|
return {
|
||||||
value: buffer.toString("utf8", 0, size),
|
value: buffer.toString("utf8", 0, size),
|
||||||
rest: buffer.subarray(size),
|
rest: buffer.subarray(size),
|
||||||
|
@ -345,7 +346,7 @@ export class Bert {
|
||||||
decode_list = (buffer) => {
|
decode_list = (buffer) => {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
const size = this.bytesToInt(buffer, 4, true);
|
const size = this.bytesToInt(buffer, 4, true);
|
||||||
buffer = Buffer.from(buffer, 4);
|
buffer = buffer.subarray(4);
|
||||||
for (let i = 0; i < size; ++i) {
|
for (let i = 0; i < size; ++i) {
|
||||||
const el = this.#decode(buffer);
|
const el = this.#decode(buffer);
|
||||||
arr.push(el.value);
|
arr.push(el.value);
|
||||||
|
|
|
@ -391,9 +391,9 @@ export class Bert {
|
||||||
};
|
};
|
||||||
|
|
||||||
decode_string = (buffer: Buffer) => {
|
decode_string = (buffer: Buffer) => {
|
||||||
const size = this.bytesToInt(buffer, 2, true);
|
const sizeLen = this.convention == Lang.ELIXIR ? 4 : 2;
|
||||||
|
const size = this.bytesToInt(buffer, sizeLen, true);
|
||||||
buffer = buffer.subarray(2);
|
buffer = buffer.subarray(sizeLen);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
value: buffer.toString("utf8", 0, size),
|
value: buffer.toString("utf8", 0, size),
|
||||||
|
@ -404,7 +404,7 @@ export class Bert {
|
||||||
decode_list = (buffer: Buffer) => {
|
decode_list = (buffer: Buffer) => {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
const size = this.bytesToInt(buffer, 4, true);
|
const size = this.bytesToInt(buffer, 4, true);
|
||||||
buffer = Buffer.from(buffer, 4);
|
buffer = buffer.subarray(4);
|
||||||
|
|
||||||
for (let i = 0; i < size; ++i) {
|
for (let i = 0; i < size; ++i) {
|
||||||
const el = this.#decode(buffer);
|
const el = this.#decode(buffer);
|
||||||
|
|
Loading…
Reference in New Issue