Skip to content

Instantly share code, notes, and snippets.

@febuiles
Created October 30, 2009 20:48
Show Gist options
  • Save febuiles/222709 to your computer and use it in GitHub Desktop.
Save febuiles/222709 to your computer and use it in GitHub Desktop.
(defun decode-entities (dirty-string)
"Interprets a string of space-separated numbers as an
ASCII string"
(mapconcat (lambda (x) (format "%c" (string-to-number x)))
(split-string (clean-encoded-string dirty-string))
""))
(defun clean-encoded-string (string)
"Removes useless characters and replaces linebreaks with a
line-feed (LF) char."
(gsub ";" " " ; add an empty space to split-string later
(gsub "&#" "" ; first 2 characters are useless
(gsub "\\(\n\\|<br />\\)" "&#10; " string)))) ; replace line break with LF (10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment