changeset 97195:a9b68f965d97

(encode-coding-char): New optional arg CHARSET.
author Kenichi Handa <handa@m17n.org>
date Fri, 01 Aug 2008 12:46:30 +0000
parents d45e07b45d86
children 15d4d10ad710
files lisp/international/mule-cmds.el
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/mule-cmds.el	Fri Aug 01 11:48:29 2008 +0000
+++ b/lisp/international/mule-cmds.el	Fri Aug 01 12:46:30 2008 +0000
@@ -2788,9 +2788,11 @@
      (function (lambda (x) (format "#x%02X" x))))
    str " "))
 
-(defun encode-coding-char (char coding-system)
+(defun encode-coding-char (char coding-system &optional charset)
   "Encode CHAR by CODING-SYSTEM and return the resulting string.
-If CODING-SYSTEM can't safely encode CHAR, return nil."
+If CODING-SYSTEM can't safely encode CHAR, return nil.
+The 3rd optional argument CHARSET, if non-nil, is a charset preferred
+on encoding."
   (let* ((str1 (string-as-multibyte (string char)))
 	 (str2 (string-as-multibyte (string char char)))
 	 (found (find-coding-systems-string str1))
@@ -2806,6 +2808,9 @@
 	;; string and two-char string, then check how many bytes at the
 	;; tail of both encoded strings are the same.
 
+	(when charset
+	  (put-text-property 0 1 'charset charset str1)
+	  (put-text-property 0 2 'charset charset str2))
 	(setq enc1 (encode-coding-string str1 coding-system)
 	      i1 (length enc1)
 	      enc2 (encode-coding-string str2 coding-system)