- if (c <= MAX_CHAR_BASIC_LATIN)
- {
- *charset = Vcharset_ascii;
- *c1 = c;
- *c2 = 0;
- }
- else if (c < 0xA0)
- {
- *charset = Vcharset_control_1;
- *c1 = c & 0x7f;
- *c2 = 0;
- }
- else if (c <= 0xff)
- {
- *charset = Vcharset_latin_iso8859_1;
- *c1 = c & 0x7f;
- *c2 = 0;
- }
- else if (c <= 0x17f)
- {
- *charset
- = CHARSET_BY_LEADING_BYTE (latin_a_char_to_charset[c - 0x100]);
-
- if (EQ (*charset, Vcharset_latin_iso8859_2))
- {
- *c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_2);
- *c2 = 0;
- }
- else if (EQ (*charset, Vcharset_latin_iso8859_3))
- {
- *c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_3);
- *c2 = 0;
- }
- else if (EQ (*charset, Vcharset_latin_iso8859_4))
- {
- *c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_4);
- *c2 = 0;
- }
- else if (EQ (*charset, Vcharset_latin_iso8859_9))
- {
- *c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_9);
- *c2 = 0;
- }
- else
- {
- *c1 = latin_a_char_to_byte1[c - 0x100];
- *c2 = latin_a_char_to_byte2[c - 0x100];
- }
- }
- else if (c < MIN_CHAR_GREEK)
- {
- if ( (*c1 = get_byte_from_character_table (c, ucs_to_latin_iso8859_2)) )
- {
- *charset = Vcharset_latin_iso8859_2;
- *c2 = 0;
- }
- else if ( (*c1 =
- get_byte_from_character_table (c, ucs_to_latin_iso8859_3)) )
- {
- *charset = Vcharset_latin_iso8859_3;
- *c2 = 0;
- }
- else if ( (*c1 =
- get_byte_from_character_table (c, ucs_to_latin_iso8859_4)) )
- {
- *charset = Vcharset_latin_iso8859_4;
- *c2 = 0;
- }
- else if ( (*c1 =
- get_byte_from_character_table (c, ucs_to_latin_iso8859_9)) )
- {
- *charset = Vcharset_latin_iso8859_9;
- *c2 = 0;
- }
- else if ( (*c1 =
- get_byte_from_character_table (c,
- ucs_to_latin_viscii_lower)) )
- {
- *charset = Vcharset_latin_viscii_lower;
- *c2 = 0;
- }
- else if ( (*c1 =
- get_byte_from_character_table (c,
- ucs_to_latin_viscii_upper)) )
- {
- *charset = Vcharset_latin_viscii_upper;
- *c2 = 0;
- }
- else
- {
- *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)
- {
- *charset = Vcharset_thai_tis620;
- *c1 = c - MIN_CHAR_THAI + 0x20;
- *c2 = 0;
- }
- else if (c < MIN_CHAR_HALFWIDTH_KATAKANA)
+ if (XCHARSET_DIMENSION (charset) == 1)
+ return DECODE_CHAR (charset, c1);
+ else
+ return DECODE_CHAR (charset, (c1 << 8) | c2);
+}
+
+extern Lisp_Object Vcharacter_attribute_table;
+
+int encode_builtin_char_1 (Emchar c, Lisp_Object* charset);
+int range_charset_code_point (Lisp_Object charset, Emchar ch);
+
+INLINE_HEADER int charset_code_point (Lisp_Object charset, Emchar ch);
+INLINE_HEADER int
+charset_code_point (Lisp_Object charset, Emchar ch)
+{
+ Lisp_Object encoding_table = XCHARSET_ENCODING_TABLE (charset);
+ Lisp_Object ret;
+
+ if ( CHAR_ID_TABLE_P (encoding_table)
+ && INTP (ret = get_char_id_table (ch, encoding_table)) )
+ return XINT (ret);
+ else
+ return range_charset_code_point (charset, ch);
+}
+
+extern Lisp_Object Vdefault_coded_charset_priority_list;
+EXFUN (Ffind_charset, 1);
+
+INLINE_HEADER int encode_char_1 (Emchar ch, Lisp_Object* charset);
+INLINE_HEADER int
+encode_char_1 (Emchar ch, Lisp_Object* charset)
+{
+ Lisp_Object charsets = Vdefault_coded_charset_priority_list;
+
+ while (!NILP (charsets))