Function: kkp--format-bytes-and-readable

kkp--format-bytes-and-readable is a natively compiled function defined in kkp.el.

Signature

(kkp--format-bytes-and-readable BYTES)

Documentation

Return a string describing BYTES in both byte list and human-readable form.

BYTES is a list of character codes (integers), or a string (converted via string-to-list). Human-readable: ESC as \e, other control chars as \xNN.

Source Code

;; Defined in /nix/store/0igl9q4k4n87vg4h2gnnrlha21kx9biv-emacs-packages-deps/share/emacs/site-lisp/elpa/kkp-20260706.858/kkp.el
(defun kkp--format-bytes-and-readable (bytes)
  "Return a string describing BYTES in both byte list and human-readable form.
BYTES is a list of character codes (integers), or a string (converted via
string-to-list).  Human-readable: ESC as \\e, other control chars as \\xNN."
  (when (stringp bytes)
    (setq bytes (string-to-list bytes)))
  (if (null bytes)
      "bytes=() readable=\"\""
    (let ((bytes-str (format "%s" bytes))
          (readable (mapconcat (lambda (b)
                                 (cond ((eq b 27) "\\e")
                                       ((and (>= b 0) (< b 32)) (format "\\x%02x" b))
                                       ((= b 127) "\\x7f")
                                       ((>= b 128) (format "\\x%02x" b))
                                       (t (string b))))
                               bytes "")))
      (format "bytes=%s readable=%S" bytes-str readable))))