From 236c7a4b3fc5662adc6157e3aca2e3c9b218cdff Mon Sep 17 00:00:00 2001 From: deveco_xdevice Date: Tue, 5 Nov 2024 19:48:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A4=84=E7=90=86hdc=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: deveco_xdevice --- plugins/ohos/src/ohos/environment/dmlib.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/ohos/src/ohos/environment/dmlib.py b/plugins/ohos/src/ohos/environment/dmlib.py index c797309..d0f4d91 100644 --- a/plugins/ohos/src/ohos/environment/dmlib.py +++ b/plugins/ohos/src/ohos/environment/dmlib.py @@ -58,6 +58,7 @@ ID_LIST = b'LIST' ID_DENT = b'DENT' DEFAULT_ENCODING = "utf-8" +COMPATIBLE_ENCODING = "ISO-8850-1" SYNC_DATA_MAX = 64 * 1024 REMOTE_PATH_MAX_LENGTH = 1024 SOCK_DATA_MAX = 256 @@ -995,10 +996,12 @@ class HdcHelper: """ Converts an HDC reply to a string. """ - try: - return str(reply, encoding=DEFAULT_ENCODING) - except (ValueError, TypeError) as _: - return "" + for encoding in [DEFAULT_ENCODING, COMPATIBLE_ENCODING]: + try: + return str(reply, encoding=encoding) + except (ValueError, TypeError) as _: + continue + return encoding @staticmethod def socket(host=None, port=None, timeout=None): From 06f3661e20067144a5306539e9dbc09dadfcfc07 Mon Sep 17 00:00:00 2001 From: deveco_xdevice Date: Tue, 5 Nov 2024 20:03:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=84=E7=90=86hdc=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: deveco_xdevice --- plugins/ohos/src/ohos/environment/dmlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ohos/src/ohos/environment/dmlib.py b/plugins/ohos/src/ohos/environment/dmlib.py index d0f4d91..9d4bcf7 100644 --- a/plugins/ohos/src/ohos/environment/dmlib.py +++ b/plugins/ohos/src/ohos/environment/dmlib.py @@ -1001,7 +1001,7 @@ class HdcHelper: return str(reply, encoding=encoding) except (ValueError, TypeError) as _: continue - return encoding + return "" @staticmethod def socket(host=None, port=None, timeout=None):