- if (c < 0x100)
- {
- Lisp_Object charsets = Vdefault_preferred_coded_charset_list;
- while (!EQ (charsets, Qnil))
- {
- *charset = Ffind_charset (Fcar (charsets));
- if (!EQ (*charset, Qnil)
- && (*c1 = charset_get_byte1 (*charset, c)) )
- {
- *c2 = charset_get_byte2 (*charset, c);
- return;
- }
- charsets = Fcdr (charsets);
- }
- /* otherwise */
- if (c <= MAX_CHAR_BASIC_LATIN)
- {
- *charset = Vcharset_ascii;
- *c1 = charset_get_byte1 (*charset, c);
- *c2 = charset_get_byte2 (*charset, c);
- }
- else if (c < 0xA0)
- {
- *charset = Vcharset_control_1;
- *c1 = charset_get_byte1 (*charset, c);
- *c2 = charset_get_byte2 (*charset, c);
- }
- else if (c <= 0xff)
- {
- *charset = Vcharset_latin_iso8859_1;
- *c1 = charset_get_byte1 (*charset, c);
- *c2 = charset_get_byte2 (*charset, c);
- }
- else
- {
- *charset = Vcharset_ucs_bmp;
- *c1 = c >> 8;
- *c2 = c & 0xff;
- }
- }
- else if (c <= 0x17f)
- {
- *charset
- = CHARSET_BY_LEADING_BYTE (latin_a_char_to_charset[c - 0x100]);
- if (XCHARSET_TO_BYTE1_TABLE (*charset) != NULL)
- {
- *c1 = charset_get_byte1 (*charset, c);
- *c2 = charset_get_byte2 (*charset, c);
- }
- else
- {
- *c1 = latin_a_char_to_byte1[c - 0x100];
- *c2 = latin_a_char_to_byte2[c - 0x100];
- }
- }
- else if (c < MIN_CHAR_GREEK)
- {
- Lisp_Object charsets = Vdefault_preferred_coded_charset_list;
- while (!EQ (charsets, Qnil))
- {
- *charset = Ffind_charset (Fcar (charsets));
- if (!EQ (*charset, Qnil)
- && (*c1 = charset_get_byte1 (*charset, c)) )
- {
- *c2 = charset_get_byte2 (*charset, c);
- return;
- }
- charsets = Fcdr (charsets);
- }
- /* otherwise */
- *charset = Vcharset_ucs_bmp;
- *c1 = c >> 8;
- *c2 = c & 0xff;
- }
- else if (c <= MAX_CHAR_GREEK)
- {
- *charset = Vcharset_greek_iso8859_7;
- *c1 = c - MIN_CHAR_GREEK + 0x20;
- *c2 = 0;
- }
- else if (c < MIN_CHAR_CYRILLIC)
- {
- *charset = Vcharset_ucs_bmp;
- *c1 = c >> 8;
- *c2 = c & 0xff;
- }
- else if (c <= MAX_CHAR_CYRILLIC)
- {
- *charset = Vcharset_cyrillic_iso8859_5;
- *c1 = c - MIN_CHAR_CYRILLIC + 0x20;
- *c2 = 0;
- }
- else if (c < MIN_CHAR_HEBREW)
- {
- *charset = Vcharset_ucs_bmp;
- *c1 = c >> 8;
- *c2 = c & 0xff;
- }
- else if (c <= MAX_CHAR_HEBREW)
- {
- *charset = Vcharset_hebrew_iso8859_8;
- *c1 = c - MIN_CHAR_HEBREW + 0x20;
- *c2 = 0;
- }
- else if (c < MIN_CHAR_THAI)
- {
- *charset = Vcharset_ucs_bmp;
- *c1 = c >> 8;
- *c2 = c & 0xff;
- }
- else if (c <= MAX_CHAR_THAI)