Created
October 30, 2009 20:48
-
-
Save febuiles/222709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 />\\)" " " 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