changeset 21064:90bdbe2754c8

(Fformat): Format multibyte characters by "%c" correctly. Handle padding for multibyte characters correctly.
author Kenichi Handa <handa@m17n.org>
date Wed, 04 Mar 1998 07:41:41 +0000
parents 44845df088bc
children fde58556c616
files src/editfns.c
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/editfns.c	Wed Mar 04 07:41:41 1998 +0000
+++ b/src/editfns.c	Wed Mar 04 07:41:41 1998 +0000
@@ -2299,7 +2299,17 @@
 	    if (*format == 'e' || *format == 'f' || *format == 'g')
 	      args[n] = Ffloat (args[n]);
 #endif
-	    thissize = 30;
+	    thissize = 30;	
+	    if (*format == 'c' && ! SINGLE_BYTE_CHAR_P (XINT (args[n])))
+	      {
+		if (! multibyte)
+		  {
+		    multibyte = 1;
+		    goto retry;
+		  }
+		args[n] = Fchar_to_string (args[n]);
+		thissize = XSTRING (args[n])->size_byte;
+	      }
 	  }
 #ifdef LISP_FLOAT_TYPE
 	else if (FLOATP (args[n]) && *format != 's')
@@ -2376,16 +2386,17 @@
 
 	  if (STRINGP (args[n]))
 	    {
-	      int padding, nbytes;
+	      int padding, nbytes, width;
 
 	      nbytes = copy_text (XSTRING (args[n])->data, p,
 				  XSTRING (args[n])->size_byte,
 				  STRING_MULTIBYTE (args[n]), multibyte);
+	      width = strwidth (p, nbytes);
 	      p += nbytes;
 	      nchars += XSTRING (args[n])->size;
 
 	      /* If spec requires it, pad on right with spaces.  */
-	      padding = minlen - XSTRING (args[n])->size;
+	      padding = minlen - width;
 	      while (padding-- > 0)
 		{
 		  *p++ = ' ';