emacs

html-entity-encode-string for Uppie

Submitted by reeses on Thu, 2003-03-20 02:33. |

For Uppie:

(defun html-entity-encode-string (s)

"Convert a string into HTML entities."

(apply #'concat (mapcar (lambda (c) (format "&#%d;" c)) (string-to-list s))))

(defun html-entity-decode-string (s)

"Convert a string from HTML entities to plain text."

(concat (mapcar (lambda (l) (string-to-number (substring l 2)))

(delete "" (split-string s ";")))))

(defun html-entity-encode-selection (start end)

"Convert the selection into HTML entities."

(interactive "r")

(replace-rectangle start end