Subject: bug#52263: Stale comment in xsd-regexp.el about Emacs not supporting Unicode

From: Stefan Kangas <[email-masked]>
Date: Sun, 5 Dec 2021 18:34:32 +0100

Eli Zaretskii <[email-masked]> writes:

> Also, decode-char is now a no-op when the 1st arg is 'ucs'.

Interesting.  So the attached cleanup should be okay to install, then?
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index 92e04f9d2e..ddc228e490 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -31,7 +31,7 @@ mm-mime-mule-charset-alist
 
 (defun mm-ucs-to-char (codepoint)
   "Convert Unicode codepoint to character."
-  (or (decode-char 'ucs codepoint) ?#))
+  (or codepoint ?#))
 
 (defvar mm-coding-system-list nil)
 (defun mm-get-coding-system-list ()
diff --git a/lisp/language/hanja-util.el b/lisp/language/hanja-util.el
index 9e9213536c..fe6323d42b 100644
--- a/lisp/language/hanja-util.el
+++ b/lisp/language/hanja-util.el
@@ -6573,8 +6573,8 @@ hangul-to-hanja-char
            (hanja-filter (lambda (x) (car x))
                          (mapcar (lambda (c)
                                    (if (listp c)
-                                       (cons (decode-char 'ucs (car c)) (cdr c))
-				     (list (decode-char 'ucs c))))
+                                       (cons (car c) (cdr c))
+                                     (list c)))
                                  (aref hanja-table char)))))
     (unwind-protect
 	(when (aref hanja-conversions 2)
diff --git a/lisp/leim/quail/hangul.el b/lisp/leim/quail/hangul.el
index c03e86b33c..d069b5b68e 100644
--- a/lisp/leim/quail/hangul.el
+++ b/lisp/leim/quail/hangul.el
@@ -429,7 +429,7 @@ hangul3-input-method-internal
            (hangul3-input-method-jong char))
           (t
            (setq hangul-queue (make-vector 6 0))
-           (insert (decode-char 'ucs char))
+           (insert char)
            (move-overlay quail-overlay (point) (point))))))
 
 (defun hangul3-input-method (key)
@@ -476,7 +476,7 @@ hangul390-input-method-internal
            (hangul3-input-method-jong char))
           (t
            (setq hangul-queue (make-vector 6 0))
-           (insert (decode-char 'ucs char))
+           (insert char)
            (move-overlay quail-overlay (point) (point))))))
 
 (defun hangul390-input-method (key)
diff --git a/lisp/nxml/rng-cmpct.el b/lisp/nxml/rng-cmpct.el
index dd3000773f..1476aa0e5a 100644
--- a/lisp/nxml/rng-cmpct.el
+++ b/lisp/nxml/rng-cmpct.el
@@ -369,7 +369,7 @@ rng-c-process-escapes
     (while (re-search-forward "\\\\x+{\\([[:xdigit:]]+\\)}"
 			      (point-max)
 			      t)
-      (let* ((ch (decode-char 'ucs (string-to-number (match-string 1) 16))))
+      (let* ((ch (string-to-number (match-string 1) 16)))
 	(if (and ch (> ch 0))
 	    (let ((begin (match-beginning 0))
 		  (end (match-end 0)))
diff --git a/lisp/nxml/xmltok.el b/lisp/nxml/xmltok.el
index 6159e00c51..503bb7d38f 100644
--- a/lisp/nxml/xmltok.el
+++ b/lisp/nxml/xmltok.el
@@ -943,7 +943,6 @@ xmltok-scan-char-ref
 	(let ((n (string-to-number (buffer-substring-no-properties start end)
 				base)))
 	  (cond ((and (integerp n) (xmltok-valid-char-p n))
-		 (setq n (xmltok-unicode-to-char n))
 		 (and n (string n)))
 		(t
 		 (xmltok-add-error "Invalid character code" start end)
@@ -971,10 +970,8 @@ xmltok-valid-char-p
 	(t (and (> n #xFFFF)
 		(< n #x110000)))))
 
-(defun xmltok-unicode-to-char (n)
-  "Return the character corresponding to Unicode scalar value N.
-Return nil if unsupported in Emacs."
-  (decode-char 'ucs n))
+(define-obsolete-function-alias 'xmltok-unicode-to-char
+  #'identity "29.1")
 
 ;;; Prolog parsing
 
diff --git a/lisp/nxml/xsd-regexp.el b/lisp/nxml/xsd-regexp.el
index 3c29803ab9..d6eaf7cc4b 100644
--- a/lisp/nxml/xsd-regexp.el
+++ b/lisp/nxml/xsd-regexp.el
@@ -287,7 +287,7 @@ xsdre-compile-char-class
 (defun xsdre-compile-single-char (ch)
   (if (memq ch '(?. ?* ?+ ?? ?\[ ?\] ?^ ?$ ?\\))
       (string ?\\ ch)
-    (string (decode-char 'ucs ch))))
+    (string ch)))
 
 (defun xsdre-char-class-to-range-list (cc)
   "Return a range-list for a symbolic char-class CC."
@@ -404,10 +404,6 @@ xsdre-range-list-to-char-alternative
 		    (cons last chars)
 		  (cons last (cons ?- chars))))))
       (setq range-list (cdr range-list)))
-    (setq chars
-	  (mapcar (lambda (c)
-		    (decode-char 'ucs c))
-		  chars))
     (when caret
       (setq chars (cons ?^ chars)))
     (when hyphen
diff --git a/lisp/xml.el b/lisp/xml.el
index 0282e3741c..e2ba02e195 100644
--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -612,8 +612,8 @@ xml-parse-string
 	(if (setq ref (match-string 2))
 	    (progn  ; Numeric char reference
 	      (setq val (save-match-data
-			  (decode-char 'ucs (string-to-number
-					     ref (if (match-string 1) 16)))))
+                          (string-to-number
+                           ref (if (match-string 1) 16))))
 	      (and (null val)
 		   xml-validating-parser
 		   (error "XML: (Validity) Invalid character reference `%s'"
@@ -898,11 +898,11 @@ xml--entity-replacement-text
 	    ref val)
 	(cond ((setq ref (match-string 1 string))
 	       ;; Decimal character reference
-	       (setq val (decode-char 'ucs (string-to-number ref)))
+               (setq val (string-to-number ref))
 	       (if val (push (string val) children)))
 	      ;; Hexadecimal character reference
 	      ((setq ref (match-string 2 string))
-	       (setq val (decode-char 'ucs (string-to-number ref 16)))
+               (setq val (string-to-number ref 16))
 	       (if val (push (string val) children)))
 	      ;; Parameter entity reference
 	      ((setq ref (match-string 3 string))
@@ -962,7 +962,7 @@ xml-substitute-special
 	(if ref
 	    ;; [4.6] Character references are included as
 	    ;; character data.
-	    (let ((val (decode-char 'ucs (string-to-number ref (if is-hex 16)))))
+            (let ((val (string-to-number ref (if is-hex 16))))
 	      (push (cond (val (string val))
 			  (xml-validating-parser
 			   (error "XML: (Validity) Undefined character `x%s'" ref))