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

(html-entity-encode-string (buffer-substring start end))))

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

"Convert the selection from HTML entities to plain text."

(interactive "r")

(replace-rectangle start end

(html-entity-decode-string (buffer-substring start end))))

Post new comment

Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.