From ab263a798076c028812b9a747d6c4206b8090faf Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 17 May 2019 05:42:12 +0200 Subject: [PATCH] (gui-get-selection): Avoid using `string-to-multibyte' * lisp/select.el (gui-get-selection): Avoid using `string-to-multibyte' -- instead encode as `eight-bit' if the string is unibyte. --- lisp/select.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/select.el b/lisp/select.el index c79e923b743..3ea741d383e 100644 --- a/lisp/select.el +++ b/lisp/select.el @@ -308,8 +308,15 @@ the formats available in the clipboard if TYPE is `CLIPBOARD'." ('STRING 'iso-8859-1) (_ (error "Unknown selection data type: %S" type)))))) - (setq data (if coding (decode-coding-string data coding) - (string-to-multibyte data)))) + (setq data (cond + (coding + (decode-coding-string data coding)) + ;; The last two cases are only possible in the + ;; C_STRING case. + ((multibyte-string-p data) + data) + (t + (encode-coding-string data 'eight-bit))))) (setq next-selection-coding-system nil) (put-text-property 0 (length data) 'foreign-selection data-type data)) data)) -- 2.39.5