From 1e1018df08b51e2467e1457f094d47f673daa9a9 Mon Sep 17 00:00:00 2001 From: Lutz Roeder Date: Tue, 10 Dec 2024 19:20:57 -0500 Subject: [PATCH] Update TextDecoder encoding --- source/circle.js | 2 +- source/mlnet.js | 2 +- source/paddle.js | 2 +- source/tf.js | 2 +- source/tflite.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/circle.js b/source/circle.js index 73a9a3c253..2f501a302f 100644 --- a/source/circle.js +++ b/source/circle.js @@ -115,7 +115,7 @@ circle.Model = class { if (data) { switch (metadata.name) { case 'min_runtime_version': { - const decoder = new TextDecoder(); + const decoder = new TextDecoder('utf-8'); this.runtime = decoder.decode(data); break; } diff --git a/source/mlnet.js b/source/mlnet.js index a64c2fdb5f..8e1912985e 100644 --- a/source/mlnet.js +++ b/source/mlnet.js @@ -467,7 +467,7 @@ mlnet.ModelHeader = class { const stream = this._entries.get(name) || this._entries.get(name.replace(/\//g, '\\')); if (stream) { const buffer = stream.peek(); - const decoder = new TextDecoder(); + const decoder = new TextDecoder('utf-8'); return decoder.decode(buffer); } return null; diff --git a/source/paddle.js b/source/paddle.js index 8837c7cb2a..952cad4566 100644 --- a/source/paddle.js +++ b/source/paddle.js @@ -730,7 +730,7 @@ paddle.NaiveBuffer = class { if (this.meta_version >= 2) { reader.skip(2); } - const decoder = new TextDecoder(); + const decoder = new TextDecoder('utf-8'); const opt_version = reader.read(16); const version = decoder.decode(opt_version.slice(0, opt_version.indexOf(0x00))); this.format = `Paddle Lite${version && version.match(/^v\d+\.\d+.\d+$/) ? ` ${version}` : ''}`; diff --git a/source/tf.js b/source/tf.js index afbe1c17d5..8d77511e8c 100644 --- a/source/tf.js +++ b/source/tf.js @@ -1452,7 +1452,7 @@ tf.TensorBundle.Table.Block = class { for (let i = 0; i < numRestarts; i++) { restartOffsets.push(reader.int32()); } - const decoder = new TextDecoder(); + const decoder = new TextDecoder('utf-8'); for (let i = 0; i < numRestarts; i++) { reader.seek(restartOffsets[i]); let key = ''; diff --git a/source/tflite.js b/source/tflite.js index b4fcef8f02..be7d2a5313 100644 --- a/source/tflite.js +++ b/source/tflite.js @@ -125,7 +125,7 @@ tflite.Model = class { if (data) { switch (metadata.name) { case 'min_runtime_version': { - const decoder = new TextDecoder(); + const decoder = new TextDecoder('utf-8'); this.runtime = decoder.decode(data); break; }