X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Ftext-coding.c;h=7ce8b94a882c7e488146ef9a5fa09fcbf51a74cb;hb=280624d95d3fd2fdee5e852a92cdb7457736cba8;hp=5a0ca984392adb51e288f09b825ba89b0494faa7;hpb=042049cc7b9892b641c75d4033d25c972209dc8a;p=chise%2Fxemacs-chise.git- diff --git a/src/text-coding.c b/src/text-coding.c index 5a0ca98..7ce8b94 100644 --- a/src/text-coding.c +++ b/src/text-coding.c @@ -2558,12 +2558,15 @@ reset_encoding_stream (struct encoding_stream *str) case CODESYS_UTF8: str->encode_char = &char_encode_utf8; str->finish = &char_finish_utf8; + break; case CODESYS_UCS4: str->encode_char = &char_encode_ucs4; str->finish = &char_finish_ucs4; + break; case CODESYS_SHIFT_JIS: str->encode_char = &char_encode_shift_jis; str->finish = &char_finish_shift_jis; + break; default: break; } @@ -2979,11 +2982,14 @@ char_encode_shift_jis (struct encoding_stream *str, Emchar ch, { Lisp_Object charset; unsigned int c1, c2, s1, s2; - #ifdef UTF2000 - if ( (c1 = get_byte_from_character_table (ch, ucs_to_latin_jisx0201)) ) + Lisp_Object value = charset_code_point (Vcharset_latin_jisx0201, ch); + Lisp_Object ret = Fcar (value); + + if (INTP (ret)) { charset = Vcharset_latin_jisx0201; + c1 = XINT (ret); c2 = 0; } else @@ -3422,10 +3428,10 @@ void char_encode_ucs4 (struct encoding_stream *str, Emchar ch, unsigned_char_dynarr *dst, unsigned int *flags) { - Dynarr_add (dst, ch >> 24); - Dynarr_add (dst, (ch >> 16) & 255); - Dynarr_add (dst, (ch >> 8) & 255); - Dynarr_add (dst, ch & 255); + Dynarr_add (dst, ch >> 24); + Dynarr_add (dst, ch >> 16); + Dynarr_add (dst, ch >> 8); + Dynarr_add (dst, ch ); } void @@ -4782,23 +4788,67 @@ char_encode_iso2022 (struct encoding_stream *str, Emchar ch, { int reg; - BREAKUP_CHAR (ch, charset, byte1, byte2); - ensure_correct_direction (XCHARSET_DIRECTION (charset), - codesys, dst, flags, 0); - /* Now determine which register to use. */ reg = -1; for (i = 0; i < 4; i++) { - if (EQ (charset, str->iso2022.charset[i]) || - EQ (charset, - CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i))) + Lisp_Object code_point; + + if ((CHARSETP (charset = str->iso2022.charset[i]) + && !EQ (code_point = charset_code_point (charset, ch), Qnil)) + || + (CHARSETP + (charset + = CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i)) + && !EQ (code_point = charset_code_point (charset, ch), Qnil))) { + Lisp_Object ret = Fcar (code_point); + + if (INTP (ret)) + { + byte1 = XINT (ret); + ret = Fcar (Fcdr (code_point)); + if (INTP (ret)) + byte2 = XINT (ret); + else + byte2 = 0; + } + else + { + byte1 = 0; + byte2 = 0; + } reg = i; break; } } - + if (reg == -1) + { + Lisp_Object original_default_coded_charset_priority_list + = Vdefault_coded_charset_priority_list; + + while (!EQ (Vdefault_coded_charset_priority_list, Qnil)) + { + BREAKUP_CHAR (ch, charset, byte1, byte2); + if (XCHARSET_FINAL (charset)) + goto found; + Vdefault_coded_charset_priority_list + = Fcdr (Fmemq (XCHARSET_NAME (charset), + Vdefault_coded_charset_priority_list)); + } + BREAKUP_CHAR (ch, charset, byte1, byte2); + if (!XCHARSET_FINAL (charset)) + { + charset = Vcharset_ascii; + byte1 = '~'; + } + found: + Vdefault_coded_charset_priority_list + = original_default_coded_charset_priority_list; + } + ensure_correct_direction (XCHARSET_DIRECTION (charset), + codesys, dst, flags, 0); + if (reg == -1) { if (XCHARSET_GRAPHIC (charset) != 0)