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

Clipboard can't handle emojis pasted from Windows #2603

Closed
matt335672 opened this issue Mar 22, 2023 · 3 comments · Fixed by #2794
Closed

Clipboard can't handle emojis pasted from Windows #2603

matt335672 opened this issue Mar 22, 2023 · 3 comments · Fixed by #2794

Comments

@matt335672
Copy link
Member

matt335672 commented Mar 22, 2023

This was reported by @howudodat on Gitter

Pasting this string from Windows into an RDP session results in the clipboard temporarily locking up:-

Simple Test.😥

Trying to view the string with xclip -o -selection clipboard -t STRING or xclip -o -selection clipboard -t UTF8_STRING results in xclip hanging.

An analysis shows that the string from windows breaks down as the following UTF-16 characters in the CB_FORMAT_DATA_RESPONSE:-

Char Value
S 0x53
i 0x69
m 0x6d
p 0x70
l 0x6c
e 0x65
0x20
T 0x54
e 0x65
s 0x73
t 0x74
. 02e
😥 0xd83d 0xde25

This string is passed to g_wcstombs() :-

len = g_wcstombs(0, wtext, 0);

which returns -1

If the string is pasted without the emoji, the paste succeeds.

Problem seems to be that the encoding of U+1F625 as the surrogate pair "0xd83d 0xde25" is a windows extension :-

https://en.wikipedia.org/wiki/UTF-16#Code_points_from_U+010000_to_U+10FFFF

A fix to this will avoid use of the wcstombs() and mbstowcs() calls

Edit: 2023-10-20. Surrogate pairs are NOT a Windows extension - they're part of the UTF-16 spec.

@howudodat
Copy link

just to add one comment, pasting that string from remmina running on ubuntu results in the same problem

@metalefty
Copy link
Member

I also have encountered this issue.

@matt335672
Copy link
Member Author

We're currently using UTF-8, UTF-16 (Windows) and ISO 8859-1 (VNC clipboard) that I know of. There may be others - if you can think of any please comment on this issue.

At some stage post v1.x I'll do a quick analysis of what we are using where, and what we need to do with all of these. Whether we can do this stuff locally, or whether we should be using something like ICU isn't yet clear to me at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants