- 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 ((CHARSET_UCS_MIN (XCHARSET (charset)) <= ch)
+ && (ch <= CHARSET_UCS_MAX (XCHARSET (charset))))
+ return ch - CHARSET_UCS_MIN (XCHARSET (charset))
+ + CHARSET_CODE_OFFSET (XCHARSET (charset));