From: tomo Date: Mon, 13 Sep 1999 01:44:40 +0000 (+0000) Subject: (charset_get_byte1): New function. X-Git-Tag: r21-2-19-utf-2000-0_7-0~27 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=ee2892ca767434efd7a27800f46c2510ee2d30f4;p=chise%2Fxemacs-chise.git- (charset_get_byte1): New function. (charset_get_byte2): New function. (Vdefault_preferred_coded_charset_list): New variable. (vars_of_mule_charset): Add new variable `default-preferred-coded-charset-list'. --- diff --git a/src/mule-charset.c b/src/mule-charset.c index 255b2d3..782aa9e 100644 --- a/src/mule-charset.c +++ b/src/mule-charset.c @@ -2033,6 +2033,97 @@ get_unallocated_leading_byte (int dimension) return lb; } +#ifdef UTF2000 +unsigned char +charset_get_byte1 (Lisp_Object charset, Emchar ch) +{ + Emchar_to_byte_table* table; + + if ((table = XCHARSET_TO_BYTE1_TABLE (charset)) != NULL) + return get_byte_from_character_table (ch, table); + else if (EQ (charset, Vcharset_ascii)) + return ch <= 0x7f ? ch : 0; + else if (EQ (charset, Vcharset_control_1)) + return (0x80 <= ch) && (ch < 0xA0) ? ch & 0x7f : 0; + else if (EQ (charset, Vcharset_latin_iso8859_1)) + return (0xA0 <= ch) && (ch <= 0xff) ? ch & 0x7f : 0; + else if (EQ (charset, Vcharset_cyrillic_iso8859_5)) + return (MIN_CHAR_GREEK <= ch) && (ch <= MAX_CHAR_CYRILLIC) ? + ch - MIN_CHAR_CYRILLIC + 0x20 : 0; + else if (EQ (charset, Vcharset_greek_iso8859_7)) + return (MIN_CHAR_GREEK <= ch) && (ch <= MAX_CHAR_GREEK) ? + ch - MIN_CHAR_GREEK + 0x20 : 0; + else if (EQ (charset, Vcharset_hebrew_iso8859_8)) + return (MIN_CHAR_HEBREW <= ch) && (ch <= MAX_CHAR_HEBREW) ? + ch - MIN_CHAR_HEBREW + 0x20 : 0; + else if (EQ (charset, Vcharset_thai_tis620)) + return (MIN_CHAR_THAI <= ch) && (ch <= MAX_CHAR_THAI) ? + ch - MIN_CHAR_THAI + 0x20 : 0; + else if (EQ (charset, Vcharset_katakana_jisx0201)) + return (MIN_CHAR_HALFWIDTH_KATAKANA <= ch) + && (ch <= MAX_CHAR_HALFWIDTH_KATAKANA) ? + ch - MIN_CHAR_HALFWIDTH_KATAKANA + 0x20 : 0; + else if (EQ (charset, Vcharset_ucs_bmp)) + return ch & 0xff; + else if (XCHARSET_DIMENSION (charset) == 1) + { + if (XCHARSET_CHARS (charset) == 94) + return (MIN_CHAR_94 + (XCHARSET_FINAL (charset) - '0') * 94 <= ch) + && (ch < MIN_CHAR_94 + (XCHARSET_FINAL (charset) - '0' + 1) * 94) ? + ((ch - MIN_CHAR_94) % 94) + 33 : 0; + else /* if (XCHARSET_CHARS (charset) == 96) */ + return (MIN_CHAR_96 + (XCHARSET_FINAL (charset) - '0') * 96 <= ch) + && (ch < MIN_CHAR_96 + (XCHARSET_FINAL (charset) - '0' + 1) * 96) ? + ((ch - MIN_CHAR_94) % 96) + 32 : 0; + } + else /* if (XCHARSET_DIMENSION (charset) == 2) */ + { + if (XCHARSET_CHARS (charset) == 94) + return (MIN_CHAR_94x94 + + (XCHARSET_FINAL (charset) - '0') * 94 * 94 <= ch) + && (ch < MIN_CHAR_94x94 + + (XCHARSET_FINAL (charset) - '0' + 1) * 94 * 94) ? + (((ch - MIN_CHAR_94x94) / 94) % 94) + 33 : 0; + else /* if (XCHARSET_CHARS (charset) == 96) */ + return (MIN_CHAR_96x96 + + (XCHARSET_FINAL (charset) - '0') * 96 * 96 <= ch) + && (ch < MIN_CHAR_96x96 + + (XCHARSET_FINAL (charset) - '0' + 1) * 96 * 96) ? + (((ch - MIN_CHAR_96x96) / 96) % 96) + 32 : 0; + } +} + +unsigned char +charset_get_byte2 (Lisp_Object charset, Emchar ch) +{ + if (XCHARSET_DIMENSION (charset) == 1) + return 0; + else + { + Emchar_to_byte_table* table; + + if ((table = XCHARSET_TO_BYTE2_TABLE (charset)) != NULL) + return get_byte_from_character_table (ch, table); + else if (EQ (charset, Vcharset_ucs_bmp)) + return (ch >> 8) & 0xff; + else if (XCHARSET_CHARS (charset) == 94) + return (MIN_CHAR_94x94 + + (XCHARSET_FINAL (charset) - '0') * 94 * 94 <= ch) + && (ch < MIN_CHAR_94x94 + + (XCHARSET_FINAL (charset) - '0' + 1) * 94 * 94) ? + ((ch - MIN_CHAR_94x94) % 94) + 33 : 0; + else /* if (XCHARSET_CHARS (charset) == 96) */ + return (MIN_CHAR_96x96 + + (XCHARSET_FINAL (charset) - '0') * 96 * 96 <= ch) + && (ch < MIN_CHAR_96x96 + + (XCHARSET_FINAL (charset) - '0' + 1) * 96 * 96) ? + ((ch - MIN_CHAR_96x96) % 96) + 32 : 0; + } +} + +Lisp_Object Vdefault_preferred_coded_charset_list; +#endif + /************************************************************************/ /* Basic charset Lisp functions */ @@ -2899,6 +2990,12 @@ Leading-code of private TYPE9N charset of column-width 1. DEFVAR_LISP ("utf-2000-version", &Vutf_2000_version /* Version number of UTF-2000. */ ); + + Vdefault_preferred_coded_charset_list = Qnil; + DEFVAR_LISP ("default-preferred-coded-charset-list", + &Vdefault_preferred_coded_charset_list /* +Default order of preferred coded-character-set. +*/ ); #endif }