Function: package--encode

package--encode is a byte-compiled function defined in package-x.el.gz.

Signature

(package--encode STRING)

Documentation

Encode a string by replacing some characters with XML entities.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/package-x.el.gz
(defun package--encode (string)
  "Encode a string by replacing some characters with XML entities."
  ;; We need a special case for translating "&" to "&".
  (let ((index))
    (while (setq index (string-match "[&]" string index))
      (setq string (replace-match "&" t nil string))
      (setq index (1+ index))))
  (while (string-match "[<]" string)
    (setq string (replace-match "&lt;" t nil string)))
  (while (string-match "[>]" string)
    (setq string (replace-match "&gt;" t nil string)))
  (while (string-match "[']" string)
    (setq string (replace-match "&apos;" t nil string)))
  (while (string-match "[\"]" string)
    (setq string (replace-match "&quot;" t nil string)))
  string)