Skip to content

Decode OSC 52 clipboard text as UTF-8 - #768

Merged
dakra merged 1 commit into
dakra:mainfrom
devsunb:fix-osc52-utf8
Oct 27, 2026
Merged

dakra merged 1 commit into
dakra:mainfrom
devsunb:fix-osc52-utf8

Conversation

@devsunb

@devsunb devsunb commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

When a program inside ghostel copies non-ASCII text over OSC 52 (tmux copy mode with set-clipboard on in my case), yanking it in Emacs gives octal escapes: é, 한글 and 👍 yank as \303\251, \355\225\234\352\270\200 and \360\237\221\215. Pasting into other apps is fine.

ghostel--osc52-handle puts the output of base64-decode-string on the kill ring directly, so it's a unibyte string of UTF-8 bytes. This decodes it first.

Added a non-native test covering non-ASCII text and both line ending styles. make test and make lint pass.

ghostel--osc52-handle put the result of base64-decode-string on the
kill ring as is.  That is a unibyte string of the UTF-8 bytes the
program sent, so non-ASCII text copied from a program in the terminal,
such as tmux copy mode with set-clipboard, yanked into Emacs as octal
escapes like \355\225\234.  Pasting into other applications still
worked, since the clipboard received the same bytes.  Decode the bytes
with utf-8-unix before putting them on the kill ring and the clipboard,
so line endings stay as the program sent them.
@dakra
dakra merged commit 97ec8f1 into dakra:main Oct 27, 2026
30 checks passed
@dakra

dakra commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Merged. Thanks.

@devsunb
devsunb deleted the fix-osc52-utf8 branch October 28, 2026 04:37
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.

2 participants