Function: preview--decode-^^ab
preview--decode-^^ab is a byte-compiled function defined in
preview.el.
Signature
(preview--decode-^^ab STRING CODING-SYSTEM)
Documentation
Decode ^^ sequences in STRING with CODING-SYSTEM.
Sequences of control characters such as ^^I are left untouched.
Return a new string.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/preview.el
(defun preview--decode-^^ab (string coding-system)
"Decode ^^ sequences in STRING with CODING-SYSTEM.
Sequences of control characters such as ^^I are left untouched.
Return a new string."
;; Since the given string can contain multibyte characters, decoding
;; should be performed seperately on each segment made up entirely
;; with ASCII and raw 8-bit characters.
;; Raw 8-bit characters can arise if the latex outputs multibyte
;; characters with partial ^^-quoting.
(let ((result ""))
;; Here we want to collect all the ASCII and raw 8-bit bytes,
;; excluding proper multibyte characters. The regexp
;; [^[:multibyte:]]+ serves for that purpose. The alternative
;; [\x00-\xFF]+ does the job as well at least for emacs 24-26, so
;; use it instead if the former becomes invalid in future.
;; N.B. [[:unibyte:]]+ doesn't match raw 8-bit bytes, contrary to
;; naive expectation.
(while (string-match "[^[:multibyte:]]+" string)
(setq result
(concat result
(substring string 0 (match-beginning 0))
(let ((text
(save-match-data
(preview--convert-^^ab
(match-string 0 string)))))
(decode-coding-string text coding-system)))
string (substring string (match-end 0))))
(setq result (concat result string))
result))