X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fchar-ucs.h;h=35038adbe1785b35dd45d998ff9e95f6208f611d;hb=a7018caf28cfca1998adae78b74f2d513da83838;hp=b27bbd2803235dcecbd21b59da5fbc1a98b23aca;hpb=0ad17a1fa11632d97cb655dbbdf9cde7b69ab69a;p=chise%2Fxemacs-chise.git diff --git a/src/char-ucs.h b/src/char-ucs.h index b27bbd2..35038ad 100644 --- a/src/char-ucs.h +++ b/src/char-ucs.h @@ -1,5 +1,5 @@ /* Header for UCS-4 character representation. - Copyright (C) 1999,2000 MORIOKA Tomohiko + Copyright (C) 1999,2000,2001 MORIOKA Tomohiko This file is part of XEmacs. @@ -26,6 +26,46 @@ Boston, MA 02111-1307, USA. */ #define CHAR_ASCII_P(ch) ((ch) <= 0x7F) +/************************************************************************/ +/* Char-ID Tables */ +/************************************************************************/ + +struct Lisp_Uint8_Byte_Table +{ + struct lcrecord_header header; + + unsigned char property[256]; +}; +typedef struct Lisp_Uint8_Byte_Table Lisp_Uint8_Byte_Table; + +DECLARE_LRECORD (uint8_byte_table, Lisp_Uint8_Byte_Table); +#define XUINT8_BYTE_TABLE(x) \ + XRECORD (x, uint8_byte_table, Lisp_Uint8_Byte_Table) +#define XSETUINT8_BYTE_TABLE(x, p) XSETRECORD (x, p, uint8_byte_table) +#define UINT8_BYTE_TABLE_P(x) RECORDP (x, uint8_byte_table) +#define GC_UINT8_BYTE_TABLE_P(x) GC_RECORDP (x, uint8_byte_table) +/* #define CHECK_UINT8_BYTE_TABLE(x) CHECK_RECORD (x, uint8_byte_table) + char table entries should never escape to Lisp */ + + +struct Lisp_Uint16_Byte_Table +{ + struct lcrecord_header header; + + unsigned short property[256]; +}; +typedef struct Lisp_Uint16_Byte_Table Lisp_Uint16_Byte_Table; + +DECLARE_LRECORD (uint16_byte_table, Lisp_Uint16_Byte_Table); +#define XUINT16_BYTE_TABLE(x) \ + XRECORD (x, uint16_byte_table, Lisp_Uint16_Byte_Table) +#define XSETUINT16_BYTE_TABLE(x, p) XSETRECORD (x, p, uint16_byte_table) +#define UINT16_BYTE_TABLE_P(x) RECORDP (x, uint16_byte_table) +#define GC_UINT16_BYTE_TABLE_P(x) GC_RECORDP (x, uint16_byte_table) +/* #define CHECK_UINT16_BYTE_TABLE(x) CHECK_RECORD (x, uint16_byte_table) + char table entries should never escape to Lisp */ + + struct Lisp_Byte_Table { struct lcrecord_header header; @@ -60,10 +100,11 @@ DECLARE_LRECORD (char_id_table, Lisp_Char_ID_Table); char table entries should never escape to Lisp */ -Lisp_Object get_char_id_table (Emchar ch, Lisp_Object table); +Lisp_Object get_char_id_table (Lisp_Char_ID_Table* cit, Emchar ch); extern Lisp_Object Vcharset_mojikyo; +extern Lisp_Object Vcharset_mojikyo_2022_1; extern Lisp_Object Vcharset_latin_jisx0201; @@ -73,7 +114,7 @@ extern Lisp_Object Vcharset_latin_jisx0201; typedef short Charset_ID; -#define MIN_LEADING_BYTE -0x60 +#define MIN_LEADING_BYTE -0x70 #define CHARSET_ID_OFFSET 0x00 /* ISO/IEC 10646 */ @@ -85,55 +126,87 @@ typedef short Charset_ID; /* ISO/IEC 10646 BMP */ #define LEADING_BYTE_UCS_BMP (CHARSET_ID_OFFSET - 3) -/* VISCII 1.1 */ -#define LEADING_BYTE_LATIN_VISCII (CHARSET_ID_OFFSET - 4) +/* ISO/IEC 10646 for CNS */ +#define LEADING_BYTE_UCS_CNS (CHARSET_ID_OFFSET - 5) -/* MULE VISCII-LOWER (CHARSET_ID_OFFSET_96 + '1') */ -#define LEADING_BYTE_LATIN_VISCII_LOWER (CHARSET_ID_OFFSET - 5) +/* ISO/IEC 10646 for JIS */ +#define LEADING_BYTE_UCS_JIS (CHARSET_ID_OFFSET - 6) -/* MULE VISCII-UPPER (CHARSET_ID_OFFSET_96 + '2') */ -#define LEADING_BYTE_LATIN_VISCII_UPPER (CHARSET_ID_OFFSET - 6) +/* ISO/IEC 10646 for Big5 */ +#define LEADING_BYTE_UCS_BIG5 (CHARSET_ID_OFFSET - 9) + +/* Japanese JIS X0208-1990 2/4 2/{(8),9,10,11} 4/2 (B) */ +#define LEADING_BYTE_JAPANESE_JISX0208_1990 (CHARSET_ID_OFFSET - 10) + +/* Chinese GB 12345-1990 */ +#define LEADING_BYTE_CHINESE_GB12345 (CHARSET_ID_OFFSET - 11) + +#define LEADING_BYTE_CHINESE_BIG5 (CHARSET_ID_OFFSET - 20) /* Big5 Level 1 2/4 2/{(8),9,10,11} 4/0 '0' */ -#define LEADING_BYTE_CHINESE_BIG5_1 (CHARSET_ID_OFFSET - 7) +#define LEADING_BYTE_CHINESE_BIG5_1 (CHARSET_ID_OFFSET - 21) /* Big5 Level 2 2/4 2/{(8),9,10,11} 4/0 '1' */ -#define LEADING_BYTE_CHINESE_BIG5_2 (CHARSET_ID_OFFSET - 8) +#define LEADING_BYTE_CHINESE_BIG5_2 (CHARSET_ID_OFFSET - 22) -#define LEADING_BYTE_ETHIOPIC_UCS (CHARSET_ID_OFFSET - 9) +#define LEADING_BYTE_CHINESE_BIG5_CDP (CHARSET_ID_OFFSET - 23) -#define LEADING_BYTE_DAIKANWA (CHARSET_ID_OFFSET - 10) -#define LEADING_BYTE_DAIKANWA_EKANJI (CHARSET_ID_OFFSET - 11) -#define LEADING_BYTE_MOJIKYO (CHARSET_ID_OFFSET - 12) +/* VISCII 1.1 */ +#define LEADING_BYTE_LATIN_VISCII (CHARSET_ID_OFFSET - 24) -/* Japanese JIS X0208-1990 2/4 2/{(8),9,10,11} 4/2 (B) */ -#define LEADING_BYTE_JAPANESE_JISX0208_1990 (CHARSET_ID_OFFSET - 13) +/* MULE VISCII-LOWER (CHARSET_ID_OFFSET_96 + '1') */ +#define LEADING_BYTE_LATIN_VISCII_LOWER (CHARSET_ID_OFFSET - 25) + +/* MULE VISCII-UPPER (CHARSET_ID_OFFSET_96 + '2') */ +#define LEADING_BYTE_LATIN_VISCII_UPPER (CHARSET_ID_OFFSET - 26) + +#define LEADING_BYTE_ETHIOPIC_UCS (CHARSET_ID_OFFSET - 27) + +#define LEADING_BYTE_DAIKANWA (CHARSET_ID_OFFSET - 28) +#define LEADING_BYTE_DAIKANWA_EKANJI (CHARSET_ID_OFFSET - 29) + +#define LEADING_BYTE_GT (CHARSET_ID_OFFSET - 30) +#define LEADING_BYTE_GT_PJ_1 (CHARSET_ID_OFFSET - 31) +#define LEADING_BYTE_GT_PJ_2 (CHARSET_ID_OFFSET - 32) +#define LEADING_BYTE_GT_PJ_3 (CHARSET_ID_OFFSET - 33) +#define LEADING_BYTE_GT_PJ_4 (CHARSET_ID_OFFSET - 34) +#define LEADING_BYTE_GT_PJ_5 (CHARSET_ID_OFFSET - 35) +#define LEADING_BYTE_GT_PJ_6 (CHARSET_ID_OFFSET - 36) +#define LEADING_BYTE_GT_PJ_7 (CHARSET_ID_OFFSET - 37) +#define LEADING_BYTE_GT_PJ_8 (CHARSET_ID_OFFSET - 38) +#define LEADING_BYTE_GT_PJ_9 (CHARSET_ID_OFFSET - 39) +#define LEADING_BYTE_GT_PJ_10 (CHARSET_ID_OFFSET - 40) +#define LEADING_BYTE_GT_PJ_11 (CHARSET_ID_OFFSET - 41) + +#define LEADING_BYTE_MOJIKYO (CHARSET_ID_OFFSET - 48) +#define LEADING_BYTE_MOJIKYO_2022_1 (CHARSET_ID_OFFSET - 49) +#define LEADING_BYTE_MOJIKYO_2022_2 (CHARSET_ID_OFFSET - 50) /* Konjaku-Mojikyo font (for pseudo-JIS X 0208 encoding) */ -#define LEADING_BYTE_MOJIKYO_PJ_1 (CHARSET_ID_OFFSET - 14) -#define LEADING_BYTE_MOJIKYO_PJ_2 (CHARSET_ID_OFFSET - 15) -#define LEADING_BYTE_MOJIKYO_PJ_3 (CHARSET_ID_OFFSET - 16) -#define LEADING_BYTE_MOJIKYO_PJ_4 (CHARSET_ID_OFFSET - 17) -#define LEADING_BYTE_MOJIKYO_PJ_5 (CHARSET_ID_OFFSET - 18) -#define LEADING_BYTE_MOJIKYO_PJ_6 (CHARSET_ID_OFFSET - 19) -#define LEADING_BYTE_MOJIKYO_PJ_7 (CHARSET_ID_OFFSET - 20) -#define LEADING_BYTE_MOJIKYO_PJ_8 (CHARSET_ID_OFFSET - 21) -#define LEADING_BYTE_MOJIKYO_PJ_9 (CHARSET_ID_OFFSET - 22) -#define LEADING_BYTE_MOJIKYO_PJ_10 (CHARSET_ID_OFFSET - 23) -#define LEADING_BYTE_MOJIKYO_PJ_11 (CHARSET_ID_OFFSET - 24) -#define LEADING_BYTE_MOJIKYO_PJ_12 (CHARSET_ID_OFFSET - 25) -#define LEADING_BYTE_MOJIKYO_PJ_13 (CHARSET_ID_OFFSET - 26) -#define LEADING_BYTE_MOJIKYO_PJ_14 (CHARSET_ID_OFFSET - 27) -#define LEADING_BYTE_MOJIKYO_PJ_15 (CHARSET_ID_OFFSET - 28) -#define LEADING_BYTE_MOJIKYO_PJ_16 (CHARSET_ID_OFFSET - 29) -#define LEADING_BYTE_MOJIKYO_PJ_17 (CHARSET_ID_OFFSET - 30) -#define LEADING_BYTE_MOJIKYO_PJ_18 (CHARSET_ID_OFFSET - 31) -#define LEADING_BYTE_MOJIKYO_PJ_19 (CHARSET_ID_OFFSET - 32) -#define LEADING_BYTE_MOJIKYO_PJ_20 (CHARSET_ID_OFFSET - 33) -#define LEADING_BYTE_MOJIKYO_PJ_21 (CHARSET_ID_OFFSET - 34) +#define LEADING_BYTE_MOJIKYO_PJ_1 (CHARSET_ID_OFFSET - 51) +#define LEADING_BYTE_MOJIKYO_PJ_2 (CHARSET_ID_OFFSET - 52) +#define LEADING_BYTE_MOJIKYO_PJ_3 (CHARSET_ID_OFFSET - 53) +#define LEADING_BYTE_MOJIKYO_PJ_4 (CHARSET_ID_OFFSET - 54) +#define LEADING_BYTE_MOJIKYO_PJ_5 (CHARSET_ID_OFFSET - 55) +#define LEADING_BYTE_MOJIKYO_PJ_6 (CHARSET_ID_OFFSET - 56) +#define LEADING_BYTE_MOJIKYO_PJ_7 (CHARSET_ID_OFFSET - 57) +#define LEADING_BYTE_MOJIKYO_PJ_8 (CHARSET_ID_OFFSET - 58) +#define LEADING_BYTE_MOJIKYO_PJ_9 (CHARSET_ID_OFFSET - 59) +#define LEADING_BYTE_MOJIKYO_PJ_10 (CHARSET_ID_OFFSET - 60) +#define LEADING_BYTE_MOJIKYO_PJ_11 (CHARSET_ID_OFFSET - 61) +#define LEADING_BYTE_MOJIKYO_PJ_12 (CHARSET_ID_OFFSET - 62) +#define LEADING_BYTE_MOJIKYO_PJ_13 (CHARSET_ID_OFFSET - 63) +#define LEADING_BYTE_MOJIKYO_PJ_14 (CHARSET_ID_OFFSET - 64) +#define LEADING_BYTE_MOJIKYO_PJ_15 (CHARSET_ID_OFFSET - 65) +#define LEADING_BYTE_MOJIKYO_PJ_16 (CHARSET_ID_OFFSET - 66) +#define LEADING_BYTE_MOJIKYO_PJ_17 (CHARSET_ID_OFFSET - 67) +#define LEADING_BYTE_MOJIKYO_PJ_18 (CHARSET_ID_OFFSET - 68) +#define LEADING_BYTE_MOJIKYO_PJ_19 (CHARSET_ID_OFFSET - 69) +#define LEADING_BYTE_MOJIKYO_PJ_20 (CHARSET_ID_OFFSET - 70) +#define LEADING_BYTE_MOJIKYO_PJ_21 (CHARSET_ID_OFFSET - 71) #define MIN_LEADING_BYTE_PRIVATE MIN_LEADING_BYTE -#define MAX_LEADING_BYTE_PRIVATE (CHARSET_ID_OFFSET - 35) +#define MAX_LEADING_BYTE_PRIVATE (CHARSET_ID_OFFSET - 72) /* #define CHARSET_ID_OFFSET_94 (CHARSET_ID_OFFSET - '0') */ @@ -301,15 +374,6 @@ DECLARE_LRECORD (charset, Lisp_Charset); #define CHECK_CHARSET(x) CHECK_RECORD (x, charset) #define CONCHECK_CHARSET(x) CONCHECK_RECORD (x, charset) -#define CHARSET_TYPE_94 0 /* This charset includes 94 characters. */ -#define CHARSET_TYPE_94X94 1 /* This charset includes 94x94 characters. */ -#define CHARSET_TYPE_96 2 /* This charset includes 96 characters. */ -#define CHARSET_TYPE_96X96 3 /* This charset includes 96x96 characters. */ -#define CHARSET_TYPE_128 4 /* This charset includes 128 characters. */ -#define CHARSET_TYPE_128X128 5 /* This charset includes 128x128 characters. */ -#define CHARSET_TYPE_256 6 /* This charset includes 256 characters. */ -#define CHARSET_TYPE_256X256 7 /* This charset includes 256x256 characters. */ - #define CHARSET_LEFT_TO_RIGHT 0 #define CHARSET_RIGHT_TO_LEFT 1 @@ -391,8 +455,22 @@ CHARSET_BY_LEADING_BYTE (Charset_ID lb) #endif -#define CHARSET_BY_ATTRIBUTES(type, final, dir) \ - (chlook->charset_by_attributes[type][final]) +INLINE_HEADER Lisp_Object +CHARSET_BY_ATTRIBUTES (int chars, int dimension, int final, int dir); +INLINE_HEADER Lisp_Object +CHARSET_BY_ATTRIBUTES (int chars, int dimension, int final, int dir) +{ + int type; + + if (chars == 94) + type = 0; + else if (chars == 96) + type = 1; + else + return Qnil; + type += dimension == 1 ? 0 : 2; + return chlook->charset_by_attributes[type][final]; +} /************************************************************************/ @@ -402,15 +480,9 @@ CHARSET_BY_LEADING_BYTE (Charset_ID lb) #define MAX_CHAR_BASIC_LATIN 0x007F /* -#define MIN_CHAR_GREEK 0x0370 -#define MAX_CHAR_GREEK 0x03CF - -#define MIN_CHAR_CYRILLIC 0x0400 -#define MAX_CHAR_CYRILLIC 0x045F -*/ - #define MIN_CHAR_HEBREW 0x0590 #define MAX_CHAR_HEBREW 0x05EF +*/ #define MIN_CHAR_THAI 0x0E00 #define MAX_CHAR_THAI 0x0E5F @@ -428,11 +500,10 @@ CHARSET_BY_LEADING_BYTE (Charset_ID lb) #define MAX_CHAR_BMP 0x00FFFF -#define MIN_CHAR_MOJIKYO 0xE00000 -#define MIN_CHAR_DAIKANWA MIN_CHAR_MOJIKYO -#define MAX_CHAR_DAIKANWA 0xE0FFFF -/* #define MAX_CHAR_MOJIKYO 0xE9093F */ -#define MAX_CHAR_MOJIKYO (MIN_CHAR_MOJIKYO + 94 * 60 * 22) +#define MIN_CHAR_DAIKANWA 0x00E00000 +#define MAX_CHAR_DAIKANWA (MIN_CHAR_DAIKANWA + 50100) /* 0xE0FFFF */ +#define MIN_CHAR_MOJIKYO_0 MIN_CHAR_DAIKANWA +#define MAX_CHAR_MOJIKYO_0 (MIN_CHAR_MOJIKYO_0 + 94 * 60 * 22) #define MIN_CHAR_94 0xE90940 #define MAX_CHAR_94 (MIN_CHAR_94 + 94 * 80 - 1) @@ -446,8 +517,41 @@ CHARSET_BY_LEADING_BYTE (Charset_ID lb) #define MIN_CHAR_96x96 0xF4C000 #define MAX_CHAR_96x96 (MIN_CHAR_96x96 + 96 * 96 * 80 - 1) +#define MIN_CHAR_MOJIKYO 0x60000000 +#define MAX_CHAR_MOJIKYO (MIN_CHAR_MOJIKYO + 94 * 60 * 22) +#define MIN_CHAR_GT 0x61000000 +#define MAX_CHAR_GT (MIN_CHAR_GT + 66773) -Emchar make_builtin_char (Lisp_Object charset, int c1, int c2); +Emchar decode_builtin_char (Lisp_Object charset, int code_point); + +INLINE_HEADER int +DECODE_MOJIKYO_2022 (unsigned char b1, unsigned char b2, unsigned char b3); +INLINE_HEADER int +DECODE_MOJIKYO_2022 (unsigned char b1, unsigned char b2, unsigned char b3) +{ + if (b2 < 16 + 32) + return 0; + else if (b2 < 16 + 32 + 30) + return + (b1 - 33) * (94 * 60) + + (b2 - (16 + 32)) * 94 + + (b3 - 33) + + 1; + else if (b2 < 18 + 32 + 30) + return 0; + else if (b2 < 18 + 32 + 60) + return + (b1 - 33) * (94 * 60) + + (b2 - (18 + 32)) * 94 + + (b3 - 33) + + 1; + else + return 0; +} + +extern Lisp_Object Vcharset_chinese_big5; +extern Lisp_Object Vcharset_chinese_big5_1; +extern Lisp_Object Vcharset_chinese_big5_2; INLINE_HEADER Emchar DECODE_CHAR (Lisp_Object charset, int code_point); INLINE_HEADER Emchar @@ -476,37 +580,60 @@ DECODE_CHAR (Lisp_Object charset, int code_point) break; } if (XCHARSET_DIMENSION (charset) == 1) - return make_builtin_char (charset, code_point, 0); + return decode_builtin_char (charset, code_point); + else if (EQ (charset, Vcharset_chinese_big5_1)) + { + unsigned int I + = ((code_point >> 8) - 33) * (0xFF - 0xA1) + + ((code_point & 0xFF) - 33); + unsigned char b1 = I / (0xFF - 0xA1 + 0x7F - 0x40) + 0xA1; + unsigned char b2 = I % (0xFF - 0xA1 + 0x7F - 0x40); + + b2 += b2 < 0x3F ? 0x40 : 0x62; + return DECODE_CHAR (Vcharset_chinese_big5, (b1 << 8) | b2); + } + else if (EQ (charset, Vcharset_chinese_big5_2)) + { + unsigned int I + = ((code_point >> 8) - 33) * (0xFF - 0xA1) + + ((code_point & 0xFF) - 33); + unsigned char b1, b2; + + I += (0xFF - 0xA1 + 0x7F - 0x40) * (0xC9 - 0xA1); + b1 = I / (0xFF - 0xA1 + 0x7F - 0x40) + 0xA1; + b2 = I % (0xFF - 0xA1 + 0x7F - 0x40); + b2 += b2 < 0x3F ? 0x40 : 0x62; + return DECODE_CHAR (Vcharset_chinese_big5, (b1 << 8) | b2); + } + else if (EQ (charset, Vcharset_mojikyo_2022_1)) + { + int m = + DECODE_MOJIKYO_2022 + ((unsigned char)(code_point >> 16), + (unsigned char)(code_point >> 8), + (unsigned char) code_point); + + if (m > 0) + return DECODE_CHAR (Vcharset_mojikyo, m); + else + return ' '; + } else { int plane = LEADING_BYTE_MOJIKYO_PJ_1 - XCHARSET_ID (charset); if ( (0 <= plane) && (plane <= 21) ) { - int c1 = code_point >> 8; - int c2 = code_point & 255; - - if (c1 < 16 + 32) - return ' '; - else if (c1 < 16 + 32 + 30) - return DECODE_CHAR (Vcharset_mojikyo, - plane * (94 * 60) - + (c1 - (16 + 32)) * 94 - + (c2 - 33) - + 1); - else if (c1 < 18 + 32 + 30) - return ' '; - else if (c1 < 18 + 32 + 60) - return DECODE_CHAR (Vcharset_mojikyo, - plane * (94 * 60) - + (c1 - (18 + 32)) * 94 - + (c2 - 33) - + 1); + int m = DECODE_MOJIKYO_2022 (plane + 33, + code_point >> 8, + (unsigned char)code_point); + if (m > 0) + return DECODE_CHAR (Vcharset_mojikyo, m); else return ' '; } else - return make_builtin_char (charset, code_point >> 8, code_point & 255); + return decode_builtin_char (charset, code_point); } } @@ -536,7 +663,8 @@ charset_code_point (Lisp_Object charset, Emchar ch) Lisp_Object ret; if ( CHAR_ID_TABLE_P (encoding_table) - && INTP (ret = get_char_id_table (ch, encoding_table)) ) + && INTP (ret = get_char_id_table (XCHAR_ID_TABLE(encoding_table), + ch)) ) return XINT (ret); else return range_charset_code_point (charset, ch); @@ -560,14 +688,15 @@ encode_char_1 (Emchar ch, Lisp_Object* charset) Lisp_Object ret; if ( CHAR_ID_TABLE_P (encoding_table) - && INTP (ret = get_char_id_table (ch, encoding_table)) ) + && INTP (ret + = get_char_id_table (XCHAR_ID_TABLE(encoding_table), + ch)) ) return XINT (ret); else { - int code_point; + int code_point = range_charset_code_point (*charset, ch); - if ((code_point - = range_charset_code_point (*charset, ch)) >= 0) + if (code_point >= 0) return code_point; } } @@ -578,40 +707,14 @@ encode_char_1 (Emchar ch, Lisp_Object* charset) return encode_builtin_char_1 (ch, charset); } -INLINE_HEADER int encode_char_2 (Emchar ch, Lisp_Object* charset); -INLINE_HEADER int -encode_char_2 (Emchar ch, Lisp_Object* charset) -{ - int code_point = encode_char_1 (ch, charset); - - if (EQ (*charset, Vcharset_mojikyo)) - { - int plane, byte1, byte2; - - code_point--; - plane = code_point / (94 * 60); - byte1 = (code_point % (94 * 60)) / 94; - if (byte1 < 30) - byte1 += 16 + 32; - else - byte1 += 18 + 32; - byte2 = code_point % 94 + 33; - *charset - = CHARSET_BY_LEADING_BYTE (LEADING_BYTE_MOJIKYO_PJ_1 - plane); - return (byte1 << 8) | byte2; - } - else - return code_point; -} - -#define ENCODE_CHAR(ch, charset) encode_char_2 (ch, &(charset)) +#define ENCODE_CHAR(ch, charset) encode_char_1 (ch, &(charset)) INLINE_HEADER void breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2); INLINE_HEADER void breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2) { - int code_point = encode_char_2 (c, charset); + int code_point = encode_char_1 (c, charset); if (code_point >= 0) { @@ -656,6 +759,32 @@ typedef struct Charc int code_point; } Charc; +INLINE_HEADER Charc CHAR_TO_CHARC (Emchar ch); +INLINE_HEADER Charc +CHAR_TO_CHARC (Emchar ch) +{ + Charc cc; + + cc.code_point = encode_char_1 (ch, &cc.charset); + if (EQ (cc.charset, Vcharset_mojikyo)) + { + int plane, byte1, byte2; + + cc.code_point--; + plane = cc.code_point / (94 * 60); + byte1 = (cc.code_point % (94 * 60)) / 94; + if (byte1 < 30) + byte1 += 16 + 32; + else + byte1 += 18 + 32; + byte2 = cc.code_point % 94 + 33; + cc.charset + = CHARSET_BY_LEADING_BYTE (LEADING_BYTE_MOJIKYO_PJ_1 - plane); + cc.code_point = (byte1 << 8) | byte2; + } + return cc; +} + /************************************************************************/ /* Exported functions */ @@ -663,9 +792,14 @@ typedef struct Charc EXFUN (Fget_charset, 1); -extern Lisp_Object Vcharset_chinese_big5_1; -extern Lisp_Object Vcharset_chinese_big5_2; +extern Lisp_Object Qucs; + extern Lisp_Object Vcharset_japanese_jisx0208; +extern Lisp_Object Vcharset_japanese_jisx0208_1990; extern Lisp_Object Vcharset_japanese_jisx0212; +Lisp_Object put_char_ccs_code_point (Lisp_Object character, + Lisp_Object ccs, Lisp_Object value); +Lisp_Object remove_char_ccs (Lisp_Object character, Lisp_Object ccs); + #endif /* INCLUDED_char_ucs_h_ */