Skip to content

Commit

Permalink
detect utf8 clipboard text and handle it correctly (#4233)
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed May 23, 2024
1 parent 5323058 commit 5f5a05a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion xpra/platform/win32/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5f5a05a

Please sign in to comment.