Function: url-insert-entities-in-string
url-insert-entities-in-string is an autoloaded and byte-compiled
function defined in url-util.el.gz.
Signature
(url-insert-entities-in-string STRING)
Documentation
Convert HTML markup-start characters to entity references in STRING.
Also replaces the " character, so that the result may be safely used as
an attribute value in a tag. Returns a new string with the result of the
conversion. Replaces these characters as follows:
& ==> &
< ==> <
> ==> >
" ==> "
Source Code
;; Defined in /usr/src/emacs/lisp/url/url-util.el.gz
;;;###autoload
(defun url-insert-entities-in-string (string)
"Convert HTML markup-start characters to entity references in STRING.
Also replaces the \" character, so that the result may be safely used as
an attribute value in a tag. Returns a new string with the result of the
conversion. Replaces these characters as follows:
& ==> &
< ==> <
> ==> >
\" ==> ""
(if (string-match "[&<>\"]" string)
(with-current-buffer (get-buffer-create " *entity*")
(erase-buffer)
(buffer-disable-undo (current-buffer))
(insert string)
(goto-char (point-min))
(while (progn
(skip-chars-forward "^&<>\"")
(not (eobp)))
(insert (cdr (assq (char-after (point))
'((?\" . """)
(?& . "&")
(?< . "<")
(?> . ">")))))
(delete-char 1))
(buffer-string))
string))