bug fix: arabic chars

This commit is contained in:
usmannasir
2025-07-05 14:37:42 +05:00
parent dd0d9f73c8
commit 27d70e00a5

View File

@@ -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