From: Lars Ingebrigtsen Date: Fri, 17 May 2019 03:42:12 +0000 (+0200) Subject: (gui-get-selection): Avoid using `string-to-multibyte' X-Git-Tag: emacs-27.0.90~2858 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ab263a798076c028812b9a747d6c4206b8090faf;p=emacs.git (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. --- 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))