From 54c6662fb1fe6fe5c6ac26e2f2b460a4486ff246 Mon Sep 17 00:00:00 2001 From: Ivan Moreno <33256758+B16f00t@users.noreply.github.com> Date: Sat, 25 Jan 2025 12:20:51 +0100 Subject: [PATCH] Update py_win_style.py Fixes issues with accented characters and special symbols by handling Unicode decoding errors. Attempts decoding with UTF-8 first, then falls back to Windows-1252 encoding if UTF-8 fails. --- pywinstyles/py_win_style.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pywinstyles/py_win_style.py b/pywinstyles/py_win_style.py index fe41ddf..16725c0 100644 --- a/pywinstyles/py_win_style.py +++ b/pywinstyles/py_win_style.py @@ -202,7 +202,12 @@ def py_drop_func(hwnd, msg, wp, lp): files = [] for i in range(count): func_DragQueryFile(typ(wp), i, file_buffer, sizeof(file_buffer)) - drop_name = file_buffer.value.decode("utf-8") + try: + drop_name = file_buffer.value.decode("utf-8") + except UnicodeDecodeError: + # If UTF-8 decoding fails, attempt to decode with a different encoding (e.g., Windows-1252) + drop_name = file_buffer.value.decode("Windows-1252") + files.append(drop_name) func(files) windll.shell32.DragFinish(typ(wp))