changeset 23154:a9cbf64603ca

(unibyte_char_to_multibyte): Vnonacii_translation_table will convert a 7-bit charcater. (multibyte_char_to_unibyte): Handle the case that Vnonacii_translation_table converts a multibyte charcater to a unibyte charcter of less than 128. (init_charset_once): Initialize nonascii_insert_offset and Vnonacii_translation_table.
author Kenichi Handa <handa@m17n.org>
date Mon, 31 Aug 1998 03:50:17 +0000
parents b2770410c752
children 8d75946934cf
files src/charset.c
diffstat 1 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.c	Mon Aug 31 03:50:17 1998 +0000
+++ b/src/charset.c	Mon Aug 31 03:50:17 1998 +0000
@@ -329,15 +329,23 @@
 unibyte_char_to_multibyte (c)
      int c;
 {
-  if (c >= 0240 && c < 0400)
+  if (c < 0400)
     {
       int c_save = c;
 
       if (! NILP (Vnonascii_translation_table))
-	c = XINT (Faref (Vnonascii_translation_table, make_number (c)));
-      else if (nonascii_insert_offset > 0)
-	c += nonascii_insert_offset;
-      if (c >= 0240 && (c < 0400 || ! VALID_MULTIBYTE_CHAR_P (c)))
+	{
+	  c = XINT (Faref (Vnonascii_translation_table, make_number (c)));
+	  if (c >= 0400 && ! VALID_MULTIBYTE_CHAR_P (c))
+	    c = c_save + DEFAULT_NONASCII_INSERT_OFFSET;
+	}
+      else if (c >= 0240 && nonascii_insert_offset > 0)
+	{
+	  c += nonascii_insert_offset;
+	  if (c < 0400 || ! VALID_MULTIBYTE_CHAR_P (c))
+	    c = c_save + DEFAULT_NONASCII_INSERT_OFFSET;
+	}
+      else if (c >= 0240)
 	c = c_save + DEFAULT_NONASCII_INSERT_OFFSET;
     }
   return c;
@@ -369,11 +377,16 @@
 	  temp = Faref (rev_tbl, make_number (c));
 	  if (INTEGERP (temp))
 	    c = XINT (temp);
+	  if (c >= 256)
+	    c = (c_save & 0177) + 0200;
 	}
-      else if (nonascii_insert_offset > 0)
-	c -= nonascii_insert_offset;
-      if (c < 128 || c >= 256)
-	c = (c_save & 0177) + 0200;
+      else
+	{
+	  if (nonascii_insert_offset > 0)
+	    c -= nonascii_insert_offset;
+	  if (c < 128 || c >= 256)
+	    c = (c_save & 0177) + 0200;
+	}
     }
 
   return c;
@@ -1806,6 +1819,9 @@
     val = Fcons (make_number (GENERIC_COMPOSITION_CHAR), val);
     Vgeneric_character_list = Fnreverse (val);
   }
+
+  nonascii_insert_offset = 0;
+  Vnonascii_translation_table = Qnil;
 }
 
 #ifdef emacs