changeset 24394:8159c8cb33cc

(push_key_description): If enable-multibyte-characters is non-nil, try to convert unibyte character to multibyte. For invalid multibyte character, show all bits by octal form. (Fsingle_key_description): Check the varidity of charset for a generic character.
author Kenichi Handa <handa@m17n.org>
date Wed, 24 Feb 1999 02:31:57 +0000
parents fcaabeb8aece
children 93502884159a
files src/keymap.c
diffstat 1 files changed, 25 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/keymap.c	Wed Feb 24 00:02:56 1999 +0000
+++ b/src/keymap.c	Wed Feb 24 02:31:57 1999 +0000
@@ -1845,26 +1845,38 @@
       *p++ = 'L';
     }
   else if (c == ' ')
-    {
+   {
       *p++ = 'S';
       *p++ = 'P';
       *p++ = 'C';
     }
   else if (c < 128)
     *p++ = c;
-  else if (c < 512)
-    {
-      *p++ = '\\';
-      *p++ = (7 & (c >> 6)) + '0';
-      *p++ = (7 & (c >> 3)) + '0';
-      *p++ = (7 & (c >> 0)) + '0';
-    }
   else
     {
-      unsigned char work[4], *str;
-      int i = CHAR_STRING (c, work, str);
-      bcopy (str, p, i);
-      p += i;
+      if (! NILP (current_buffer->enable_multibyte_characters))
+	c = unibyte_char_to_multibyte (c);
+
+      if (NILP (current_buffer->enable_multibyte_characters)
+	  || SINGLE_BYTE_CHAR_P (c)
+	  || ! char_valid_p (c, 0))
+	{
+	  int bit_offset;
+	  *p++ = '\\';
+	  /* The biggest character code uses 19 bits.  */
+	  for (bit_offset = 18; bit_offset >= 0; bit_offset -= 3)
+	    {
+	      if (c >= (1 << bit_offset))
+		*p++ = ((c & (7 << bit_offset)) >> bit_offset) + '0';
+	    }
+	}
+      else
+	{
+	  unsigned char work[4], *str;
+	  int i = CHAR_STRING (c, work, str);
+	  bcopy (str, p, i);
+	  p += i;
+	}
     }
 
   return p;  
@@ -1894,6 +1906,7 @@
 	SPLIT_NON_ASCII_CHAR (without_bits, charset, c1, c2);
 
       if (charset
+	  && CHARSET_DEFINED_P (charset)
 	  && ((c1 >= 0 && c1 < 32)
 	      || (c2 >= 0 && c2 < 32)))
 	{