changeset 88573:133bf7ab1bad

(encode_coding_iso_2022): If coding requires safe encoding, produce a character specified by CODING_INHIBIT_CHARACTER_SUBSTITUTION. (encode_coding_sjis): Likewise. (encode_coding_big5): Likewise. (encode_coding_charset): Likewise.
author Kenichi Handa <handa@m17n.org>
date Mon, 20 May 2002 12:10:04 +0000
parents b097ed538bd5
children 8cbbc8918e1f
files src/coding.c
diffstat 1 files changed, 37 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/coding.c	Mon May 20 12:08:00 2002 +0000
+++ b/src/coding.c	Mon May 20 12:10:04 2002 +0000
@@ -3488,8 +3488,16 @@
 
 	  if (!charset)
 	    {
-	      c = coding->default_char;
-	      charset = char_charset (c, charset_list, NULL);
+	      if (coding->mode & CODING_MODE_SAFE_ENCODING)
+		{
+		  c = CODING_INHIBIT_CHARACTER_SUBSTITUTION;
+		  charset = CHARSET_FROM_ID (charset_ascii);
+		}
+	      else
+		{
+		  c = coding->default_char;
+		  charset = char_charset (c, charset_list, NULL);
+		}
 	    }
 	  ENCODE_ISO_CHARACTER (charset, c);
 	}
@@ -3851,8 +3859,16 @@
 
 	  if (!charset)
 	    {
-	      c = coding->default_char;
-	      charset = char_charset (c, charset_list, &code);
+	      if (coding->mode & CODING_MODE_SAFE_ENCODING)
+		{
+		  code = CODING_INHIBIT_CHARACTER_SUBSTITUTION;
+		  charset = CHARSET_FROM_ID (charset_ascii);
+		}
+	      else
+		{
+		  c = coding->default_char;
+		  charset = char_charset (c, charset_list, &code);
+		}
 	    }
 	  if (code == CHARSET_INVALID_CODE (charset))
 	    abort ();
@@ -3911,8 +3927,16 @@
 
 	  if (! charset)
 	    {
-	      c = coding->default_char;
-	      charset = char_charset (c, charset_list, &code);
+	      if (coding->mode & CODING_MODE_SAFE_ENCODING)
+		{
+		  code = CODING_INHIBIT_CHARACTER_SUBSTITUTION;
+		  charset = CHARSET_FROM_ID (charset_ascii);
+		}
+	      else
+		{
+		  c = coding->default_char;
+		  charset = char_charset (c, charset_list, &code);
+		}
 	    }
 	  if (code == CHARSET_INVALID_CODE (charset))
 	    abort ();
@@ -4372,7 +4396,13 @@
 				 (code >> 8) & 0xFF, code & 0xFF);
 	    }
 	  else
-	    EMIT_ONE_BYTE (coding->default_char);
+	    {
+	      if (coding->mode & CODING_MODE_SAFE_ENCODING)
+		c = CODING_INHIBIT_CHARACTER_SUBSTITUTION;
+	      else
+		c = coding->default_char;
+	      EMIT_ONE_BYTE (c);
+	    }
 	}
     }