From 27d70e00a583b789f90b108ca4942e1e75182155 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sat, 5 Jul 2025 14:37:42 +0500 Subject: [PATCH] bug fix: arabic chars --- plogical/processUtilities.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index 793fd71e8..40c7229d7 100644 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -271,16 +271,21 @@ class ProcessUtilities(multi.Thread): sock.sendall(command.encode('utf-8')) - data = "" + # Collect all raw bytes first, then decode as a complete unit + raw_data = b"" while (1): currentData = sock.recv(32) if len(currentData) == 0 or currentData == None: break - try: - data = data + currentData.decode('utf-8', errors='replace') - except BaseException as msg: - logging.writeToFile('Some data could not be decoded to str, error message: %s' % str(msg)) + raw_data += currentData + + # Decode all data at once to prevent UTF-8 character boundary issues + try: + data = raw_data.decode('utf-8', errors='replace') + except BaseException as msg: + logging.writeToFile('Some data could not be decoded to str, error message: %s' % str(msg)) + data = "" sock.close() #logging.writeToFile('Final data: %s.' % (str(data))) @@ -433,7 +438,4 @@ class ProcessUtilities(multi.Thread): except Exception as e: print("An error occurred:", e) logging.writeToFile(f"[fetch_latest_prestashop_version] An error occurred: {str(e)}") - return None - - - + return None \ No newline at end of file