Function: consult--tofu-encode

consult--tofu-encode is a byte-compiled function defined in consult.el.

Signature

(consult--tofu-encode N)

Documentation

Return tofu-encoded number N as a string.

Large numbers are encoded as multiple tofu characters.

Source Code

;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
;; We must disambiguate the lines by adding a suffix such that two lines with
;; the same text can be distinguished.  In order to avoid matching the line
;; number, such that the user can search for numbers with `consult-line', we
;; encode the line number as Unicode PUA-B characters.  This way accidental
;; matching is unlikely.
(defun consult--tofu-encode (n)
  "Return tofu-encoded number N as a string.
Large numbers are encoded as multiple tofu characters."
  (let (str tofu)
    (while (progn
             (setq tofu (char-to-string
                         (+ consult--tofu-char (% n consult--tofu-range)))
                   str (if str (concat tofu str) tofu))
             (and (>= n consult--tofu-range)
                  (setq n (/ n consult--tofu-range)))))
    (add-text-properties 0 (length str) '(invisible t consult-strip t) str)
    str))