From 4b8baa544b402c17030e483128cb3caf3659ca23 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Thu, 23 May 2024 13:06:15 +0700 Subject: [PATCH] detect utf8 clipboard text and handle it correctly (#4233) --- xpra/platform/win32/clipboard.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xpra/platform/win32/clipboard.py b/xpra/platform/win32/clipboard.py index a8477ad0c6..62b0576a20 100644 --- a/xpra/platform/win32/clipboard.py +++ b/xpra/platform/win32/clipboard.py @@ -611,7 +611,11 @@ def got_contents(self, target: str, dtype="", dformat=0, data=b""): self.send_clipboard_request_handler(self, self._selection, image_formats[0]) elif dformat == 8 and dtype in TEXT_TARGETS: log("we got a byte string: %s", ellipsizer(data)) - self.set_clipboard_text(bytestostr(data)) + if dtype.lower().find("utf8") >= 0: + text = data.decode("utf8") + else: + text = bytestostr(data) + self.set_clipboard_text(text) elif dformat == 8 and dtype.startswith("image/"): img_format = dtype.split("/")[-1] # ie: 'png' self.set_clipboard_image(img_format, data)