Skip to content

fix: decoding Unicode on X11/Wayland in get-contents - #25

Open
imiric wants to merge 1 commit into
rolandwalker:masterfrom
imiric:fix/23-get-contents-unicode
Open

imiric wants to merge 1 commit into
rolandwalker:masterfrom
imiric:fix/23-get-contents-unicode

Conversation

@imiric

@imiric imiric commented Aug 16, 2026

Copy link
Copy Markdown

Previously if x-select-request-type was nil, simpleclip-get-contents would decode Unicode characters as Latin-1. E.g. copying "🙂" and calling simpleclip-get-contents would return:

#("\\U0001f642" 0 10 (foreign-selection nil))

The fix mirrors gui--selection-value-internal as mentioned in the previous TODO comment by trying UTF8_STRING, COMPOUND_TEXT, STRING, and text/plain;charset=utf-8 in order.

Full disclosure: this was produced with heavy assistance from LLMs, but I reviewed and tested it to the best of my abilities, and it works fine for me on Emacs 31.1 and (X)Wayland. make test passes.

Fixes #23

(Thanks for the great package! It's addressing some insane clipboard behavior for me on Wayland. 😓)

Previously if `x-select-request-type` was nil, `simpleclip-get-contents` would
decode Unicode characters as Latin-1. E.g. copying "🙂" and calling
`simpleclip-get-contents` would return:
```
\#("\\U0001f642" 0 10 (foreign-selection nil))
```

The fix mirrors `gui--selection-value-internal` as mentioned in the
previous TODO comment by trying UTF8_STRING, COMPOUND_TEXT,
STRING, and `text/plain;charset=utf-8' in order.

Full disclosure: this was produced with *heavy* assistance from LLMs,
but I reviewed and tested it to the best of my abilities, and it works
fine for me on Emacs 30.2 and (X)Wayland. `make test` passes.

Fixes rolandwalker#23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

non-ascii characters are pasted incorrectly

1 participant