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

@@ -25,7 +25,7 @@ import platform
import posixpath
import re
import serial.serialutil
import binascii
import click
import dotenv
@@ -157,9 +157,11 @@ def get(remote_file, local_file):
contents = board_files.get(remote_file)
# Print the file out if no local file was provided, otherwise save it.
if local_file is None:
print(contents.decode("utf-8"))
contents = str(contents)[2:-1]
print(contents, end='')
else:
local_file.write(contents)
value = binascii.unhexlify(contents)
local_file.write(value.decode("utf-8"))
@cli.command()