# HG changeset patch # User Kenichi Handa # Date 1021896604 0 # Node ID 133bf7ab1badf8259ed5e1cbab6943a39d86d4f9 # Parent b097ed538bd50b7ed2d4f86c1e635166e5e329a9 (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. diff -r b097ed538bd5 -r 133bf7ab1bad src/coding.c --- 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); + } } }