comparison src/coding.c @ 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 f464d728344c
children c7772f702227
comparison
equal deleted inserted replaced
88572:b097ed538bd5 88573:133bf7ab1bad
3486 { 3486 {
3487 struct charset *charset = char_charset (c, charset_list, NULL); 3487 struct charset *charset = char_charset (c, charset_list, NULL);
3488 3488
3489 if (!charset) 3489 if (!charset)
3490 { 3490 {
3491 c = coding->default_char; 3491 if (coding->mode & CODING_MODE_SAFE_ENCODING)
3492 charset = char_charset (c, charset_list, NULL); 3492 {
3493 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION;
3494 charset = CHARSET_FROM_ID (charset_ascii);
3495 }
3496 else
3497 {
3498 c = coding->default_char;
3499 charset = char_charset (c, charset_list, NULL);
3500 }
3493 } 3501 }
3494 ENCODE_ISO_CHARACTER (charset, c); 3502 ENCODE_ISO_CHARACTER (charset, c);
3495 } 3503 }
3496 } 3504 }
3497 3505
3849 unsigned code; 3857 unsigned code;
3850 struct charset *charset = char_charset (c, charset_list, &code); 3858 struct charset *charset = char_charset (c, charset_list, &code);
3851 3859
3852 if (!charset) 3860 if (!charset)
3853 { 3861 {
3854 c = coding->default_char; 3862 if (coding->mode & CODING_MODE_SAFE_ENCODING)
3855 charset = char_charset (c, charset_list, &code); 3863 {
3864 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION;
3865 charset = CHARSET_FROM_ID (charset_ascii);
3866 }
3867 else
3868 {
3869 c = coding->default_char;
3870 charset = char_charset (c, charset_list, &code);
3871 }
3856 } 3872 }
3857 if (code == CHARSET_INVALID_CODE (charset)) 3873 if (code == CHARSET_INVALID_CODE (charset))
3858 abort (); 3874 abort ();
3859 if (charset == charset_kanji) 3875 if (charset == charset_kanji)
3860 { 3876 {
3909 unsigned code; 3925 unsigned code;
3910 struct charset *charset = char_charset (c, charset_list, &code); 3926 struct charset *charset = char_charset (c, charset_list, &code);
3911 3927
3912 if (! charset) 3928 if (! charset)
3913 { 3929 {
3914 c = coding->default_char; 3930 if (coding->mode & CODING_MODE_SAFE_ENCODING)
3915 charset = char_charset (c, charset_list, &code); 3931 {
3932 code = CODING_INHIBIT_CHARACTER_SUBSTITUTION;
3933 charset = CHARSET_FROM_ID (charset_ascii);
3934 }
3935 else
3936 {
3937 c = coding->default_char;
3938 charset = char_charset (c, charset_list, &code);
3939 }
3916 } 3940 }
3917 if (code == CHARSET_INVALID_CODE (charset)) 3941 if (code == CHARSET_INVALID_CODE (charset))
3918 abort (); 3942 abort ();
3919 if (charset == charset_big5) 3943 if (charset == charset_big5)
3920 { 3944 {
4370 else 4394 else
4371 EMIT_FOUR_BYTES (code >> 24, (code >> 16) & 0xFF, 4395 EMIT_FOUR_BYTES (code >> 24, (code >> 16) & 0xFF,
4372 (code >> 8) & 0xFF, code & 0xFF); 4396 (code >> 8) & 0xFF, code & 0xFF);
4373 } 4397 }
4374 else 4398 else
4375 EMIT_ONE_BYTE (coding->default_char); 4399 {
4400 if (coding->mode & CODING_MODE_SAFE_ENCODING)
4401 c = CODING_INHIBIT_CHARACTER_SUBSTITUTION;
4402 else
4403 c = coding->default_char;
4404 EMIT_ONE_BYTE (c);
4405 }
4376 } 4406 }
4377 } 4407 }
4378 4408
4379 coding->result = CODING_RESULT_SUCCESS; 4409 coding->result = CODING_RESULT_SUCCESS;
4380 coding->produced_char += produced_chars; 4410 coding->produced_char += produced_chars;