Function: ghostel--decode-paste-bytes
ghostel--decode-paste-bytes is a natively compiled function defined in
ghostel.el.
Signature
(ghostel--decode-paste-bytes TEXT)
Documentation
Return TEXT as valid Unicode for ghostel--encode-paste.
Re-decode raw byte runs as UTF-8 and replace anything still outside the Unicode range with U+FFFD.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--decode-paste-bytes (text)
"Return TEXT as valid Unicode for `ghostel--encode-paste'.
Re-decode raw byte runs as UTF-8 and replace anything still outside
the Unicode range with U+FFFD."
(if (string-match-p "[^\x0-\x10ffff]" text)
(let ((repaired (decode-coding-string
(if (multibyte-string-p text)
(encode-coding-string text 'utf-8)
text)
'utf-8)))
(replace-regexp-in-string "[^\x0-\x10ffff]" (string #xFFFD) repaired))
text))