From: Kenichi Handa Date: Wed, 4 Mar 1998 07:41:41 +0000 (+0000) Subject: (Fformat): Format multibyte characters by "%c" X-Git-Tag: emacs-20.3~2010 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f49a2d745257638152d17a75320c61c5109cab6f;p=emacs.git (Fformat): Format multibyte characters by "%c" correctly. Handle padding for multibyte characters correctly. --- diff --git a/src/editfns.c b/src/editfns.c index 9718c5aa153..5ae0c28be6d 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -2299,7 +2299,17 @@ Use %% to put a single % into the output.") 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 @@ Use %% to put a single % into the output.") 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++ = ' ';