From 0a625ae75a0003e4dc0ac800863242f3bc46fbb4 Mon Sep 17 00:00:00 2001 From: Philipp Schuler Date: Mon, 5 May 2025 01:35:40 +0200 Subject: [PATCH] Ignore UnicodeEncodeError in lprint --- client/pyscripts/fm11rf08s_full.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/pyscripts/fm11rf08s_full.py b/client/pyscripts/fm11rf08s_full.py index b50f9c56f..8d1765b84 100644 --- a/client/pyscripts/fm11rf08s_full.py +++ b/client/pyscripts/fm11rf08s_full.py @@ -90,13 +90,14 @@ def lprint(s='', end='\n', flush=False, prompt="[" + color("=", fg="yellow") + - logfile (R) """ s = f"{prompt}" + f"\n{prompt}".join(s.split('\n')) - print(s, end=end, flush=flush) + safe_s = s.encode('utf-8', errors='ignore').decode('utf-8') + print(safe_s, end=end, flush=flush) if log is True: global logbuffer if logfile is not None: with open(logfile, 'a', encoding='utf-8') as f: - f.write(s + end) + f.write(safe_s + end) else: # buffering logbuffer += s + end