Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong encoding for text copied between linux and windows #1254

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix wrong encoding for text copied between Linux and Windows
(https://github.com/debauchee/barrier/issues/1037, https://github.com/debauchee/barrier/issues/1137).
11 changes: 9 additions & 2 deletions src/lib/platform/XWindowsClipboardHTMLConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,17 @@ XWindowsClipboardHTMLConverter::getDataSize() const

std::string XWindowsClipboardHTMLConverter::fromIClipboard(const std::string& data) const
{
return Unicode::UTF8ToUTF16(data);
return data;
}

std::string XWindowsClipboardHTMLConverter::toIClipboard(const std::string& data) const
{
return Unicode::UTF16ToUTF8(data);
// Older Firefox [1] and possibly other applications use UTF-16 for text/html - handle both
// [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1497580
if (Unicode::isUTF8(data)) {
return data;
} else {
return Unicode::UTF16ToUTF8(data);
}
return data;
}