Merge pull request #1254 from yan12125/fix-wrong-encoding-for-text-copied-between-linux-and-windows

Fix wrong encoding for text copied between linux and windows
This commit is contained in:
Povilas Kanapickas 2021-11-03 03:33:28 +02:00 committed by GitHub
commit ac5a1bfd3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -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).

View File

@ -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
{
// 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;
}