summaryrefslogtreecommitdiff
path: root/lisp/xml.el
diff options
context:
space:
mode:
authorUlf Jasper <ulf.jasper@web.de>2009-12-06 18:13:19 +0000
committerUlf Jasper <ulf.jasper@web.de>2009-12-06 18:13:19 +0000
commit571855b6310390faa67d00bef0b0bc7aa118348f (patch)
tree4d21b17a290bb167d03fdd829927730e5e078053 /lisp/xml.el
parentb857059c0aaae85bff9c897b97dcba532e93e40a (diff)
downloademacs-571855b6310390faa67d00bef0b0bc7aa118348f.tar.gz
Fixed Bug#5008.
Diffstat (limited to 'lisp/xml.el')
-rw-r--r--lisp/xml.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/lisp/xml.el b/lisp/xml.el
index e86232d5718..ac96286fdec 100644
--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -823,6 +823,25 @@ This follows the rule [28] in the XML specifications."
"")
(substring string point))))))
+(defun xml-substitute-numeric-entities (string)
+ "Substitute SGML numeric entities by their respective utf characters.
+This function replaces numeric entities in the input STRING and
+returns the modified string. For example \"&#42;\" gets replaced
+by \"*\"."
+ (if (and string (stringp string))
+ (let ((start 0))
+ (while (string-match "&#\\([0-9]+\\);" string start)
+ (condition-case nil
+ (setq string (replace-match
+ (string (read (substring string
+ (match-beginning 1)
+ (match-end 1))))
+ nil nil string))
+ (error nil))
+ (setq start (1+ (match-beginning 0))))
+ string)
+ nil))
+
;;*******************************************************************
;;**
;;** Printing a tree.