changeset 28475:5eb1da819180

(encoded-string-description): Rewritten. Try pretty description for ISO 2022 escape sequences only if CODING-SYSTEM is based on ISO 2022.
author Kenichi Handa <handa@m17n.org>
date Mon, 03 Apr 2000 04:05:41 +0000
parents baad77ad3383
children 537459659dff
files lisp/international/mule-cmds.el
diffstat 1 files changed, 7 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/mule-cmds.el	Mon Apr 03 04:05:06 2000 +0000
+++ b/lisp/international/mule-cmds.el	Mon Apr 03 04:05:41 2000 +0000
@@ -1815,23 +1815,13 @@
 (defun encoded-string-description (str coding-system)
   "Return a pretty description of STR that is encoded by CODING-SYSTEM."
   (setq str (string-as-unibyte str))
-  (let ((char (aref str 0))
-	desc)
-    (when (< char 128)
-      (setq desc (or (cdr (assq char iso-2022-control-alist))
-		     (char-to-string char)))
-      (let ((i 1)
-	    (len (length str))) 
-	(while (< i len)
-	  (setq char (aref str i))
-	  (if (>= char 128)
-	      (setq desc nil i len)
-	    (setq desc (concat desc " "
-			       (or (cdr (assq char iso-2022-control-alist))
-				   (char-to-string char)))
-		  i (1+ i))))))
-    (or desc
-	(mapconcat (function (lambda (x) (format "0x%02x" x))) str " "))))
+  (mapconcat
+   (if (eq (coding-system-type coding-system) 2)
+       ;; Try to get a pretty description for ISO 2022 escape sequences.
+       (function (lambda (x) (or (cdr (assq x iso-2022-control-alist))
+				 (format "%02X" x))))
+     (function (lambda (x) (format "0x%02x" x))))
+   str " "))
 
 (defun encode-coding-char (char coding-system)
   "Encode CHAR by CODING-SYSTEM and return the resulting string.