1. xemacs
  2. psgml


psgml / psgml-charent.el

Diff from to

File psgml-charent.el

 ;;  Functions to convert character entities into displayable characters
 ;;  and displayable characters back into character entities.
+;; This should either use iso-cvt or do better with a multilingual set of entities 
 ;;;; Code:
 (provide 'psgml-charent)
 (require 'psgml-parse)
+(eval-when-compile (require 'cl))
 ;;;; Variable declarations
 (defvar sgml-display-char-list-filename
   (expand-file-name "iso88591.map"
+                    ;; XEmacs change: use data-directory, try "sgml" too.
                      (or (locate-data-directory "psgml")
                          (locate-data-directory "sgml"))))
   "*Name of file holding relations between character codes and character
-names of displayable characters")
+names of displayable characters.")
 (defvar sgml-display-char-alist-cache nil)
   (let (key disp-char alist)
     (while (re-search-forward "^\\([0-9]+\\)[ \t]+\\(.+\\)$" nil t)
       (setq key (buffer-substring (match-beginning 2) (match-end 2)))
-      (setq disp-char
-	    (char-to-string
-	     (string-to-number
-	      (buffer-substring (match-beginning 1) (match-end 1)))))
+      (setq disp-char (string-to-number (buffer-substring (match-beginning 1)
+							  (match-end 1))))
+      (if (fboundp 'unibyte-char-to-multibyte)
+	  (setq disp-char (unibyte-char-to-multibyte disp-char)))
+      (setq disp-char (char-to-string disp-char))
       (push (cons key disp-char)
       (goto-char (point-min))
        (while (re-search-forward "&\\(\\w\\(\\w\\|\\s_\\)*\\);?" nil t)
-	 (setq charent (buffer-substring
+	 (setq charent (buffer-substring-no-properties
                         (match-beginning 1) (match-end 1)))
 	 (if (setq replacement (cdr (assoc charent charent-to-char)))
 	     (replace-match replacement t t)))))))