Fix: 修复electron环境下ampy读取文件时的中文乱码问题

This commit is contained in:
王立帮
2024-08-18 01:53:56 +08:00
parent 36428283e7
commit 996a239b11
4 changed files with 9 additions and 6 deletions

View File

@@ -23,6 +23,7 @@ class AmpyFS extends FS {
#ampy_ = null;
#port_ = '';
#baud_ = 115200;
#decoder_ = new TextDecoder('utf8');
constructor() {
super();
@@ -58,7 +59,7 @@ class AmpyFS extends FS {
try {
const output = await this.#ampy_.get(this.#port_, this.#baud_, filePath);
stdout = output.stdout;
stdout = stdout.replaceAll('\r\r', '\r');
stdout = this.#decoder_.decode(this.#ampy_.unhexlify(stdout));
} catch (e) {
error = e;
Debug.error(error);

View File

@@ -41,6 +41,7 @@ class AmpyExt extends Ampy {
ampy: this.AMPY_PATH
});
}
#exec_ = util.promisify(child_process.exec);
constructor() {