1 /* Header for UCS-4 character representation.
2 Copyright (C) 1999 Electrotechnical Laboratory, JAPAN.
3 Licensed to the Free Software Foundation.
5 This file is part of XEmacs.
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* Rewritten by MORIOKA Tomohiko <tomo@m17n.org>. */
24 #ifndef _XEMACS_CHAR_UCS_H
25 #define _XEMACS_CHAR_UCS_H
27 #define valid_char_p(ch) 1
29 #define CHAR_ASCII_P(ch) ((ch) <= 0x7F)
32 DECLARE_LRECORD (char_byte_table, struct Lisp_Char_Byte_Table);
33 #define XCHAR_BYTE_TABLE(x) \
34 XRECORD (x, char_byte_table, struct Lisp_Char_Byte_Table)
35 #define XSETCHAR_BYTE_TABLE(x, p) XSETRECORD (x, p, char_byte_table)
36 #define CHAR_BYTE_TABLE_P(x) RECORDP (x, char_byte_table)
37 #define GC_CHAR_BYTE_TABLE_P(x) GC_RECORDP (x, char_byte_table)
38 /* #define CHECK_CHAR_BYTE_TABLE(x) CHECK_RECORD (x, char_byte_table)
39 char table entries should never escape to Lisp */
41 struct Lisp_Char_Byte_Table
43 struct lcrecord_header header;
45 Lisp_Object property[256];
48 Lisp_Object get_char_code_table (Emchar ch, Lisp_Object table);
51 extern Lisp_Object Vcharset_ucs_bmp;
52 extern Lisp_Object Vcharset_latin_jisx0201;
53 extern Lisp_Object Vcharset_latin_iso8859_2;
54 extern Lisp_Object Vcharset_latin_iso8859_3;
55 extern Lisp_Object Vcharset_latin_iso8859_4;
56 extern Lisp_Object Vcharset_latin_iso8859_9;
57 extern Lisp_Object Vcharset_latin_viscii_lower;
58 extern Lisp_Object Vcharset_latin_viscii_upper;
61 /************************************************************************/
62 /* Definition of leading bytes */
63 /************************************************************************/
65 typedef int Charset_ID;
67 #define MIN_LEADING_BYTE -0x40
68 #define CHARSET_ID_OFFSET 0x00
70 /* represent normal 80-9F */
71 #define LEADING_BYTE_CONTROL_1 (CHARSET_ID_OFFSET - 1)
73 /* ISO/IEC 10646 BMP */
74 #define LEADING_BYTE_UCS_BMP (CHARSET_ID_OFFSET - 2)
77 #define LEADING_BYTE_LATIN_VISCII (CHARSET_ID_OFFSET - 3)
79 /* MULE VISCII-LOWER (CHARSET_ID_OFFSET_96 + '1') */
80 #define LEADING_BYTE_LATIN_VISCII_LOWER (CHARSET_ID_OFFSET - 4)
82 /* MULE VISCII-UPPER (CHARSET_ID_OFFSET_96 + '2') */
83 #define LEADING_BYTE_LATIN_VISCII_UPPER (CHARSET_ID_OFFSET - 5)
85 /* Big5 Level 1 2/4 2/{(8),9,10,11} 4/0 '0' */
86 #define LEADING_BYTE_CHINESE_BIG5_1 (CHARSET_ID_OFFSET - 6)
88 /* Big5 Level 2 2/4 2/{(8),9,10,11} 4/0 '1' */
89 #define LEADING_BYTE_CHINESE_BIG5_2 (CHARSET_ID_OFFSET - 7)
91 #define LEADING_BYTE_HIRAGANA_JISX0208 (CHARSET_ID_OFFSET - 8)
92 #define LEADING_BYTE_KATAKANA_JISX0208 (CHARSET_ID_OFFSET - 9)
94 #define MIN_LEADING_BYTE_PRIVATE MIN_LEADING_BYTE
95 #define MAX_LEADING_BYTE_PRIVATE (CHARSET_ID_OFFSET - 10)
98 /* #define CHARSET_ID_OFFSET_94 (CHARSET_ID_OFFSET - '0') */
100 /* #define MIN_CHARSET_ID_PRIVATE_94 (CHARSET_ID_OFFSET_94 + '0') */
101 /* #define MAX_CHARSET_ID_PRIVATE_94 (CHARSET_ID_OFFSET_94 + '?') */
104 #define LEADING_BYTE_ASCII 6 /* (CHARSET_ID_OFFSET_94 + 'B') */
106 /* Right half of JIS X0201-1976 */
107 #define LEADING_BYTE_KATAKANA_JISX0201 13 /* (CHARSET_ID_OFFSET_94 + 'I') */
109 /* Left half of JIS X0201-1976 */
110 #define LEADING_BYTE_LATIN_JISX0201 14 /* (CHARSET_ID_OFFSET_94 + 'J') */
113 /* #define CHARSET_ID_OFFSET_96 (CHARSET_ID_OFFSET_94 + 80) */
115 /* Right half of ISO 8859-1 */
116 #define LEADING_BYTE_LATIN_ISO8859_1 100 /* (CHARSET_ID_OFFSET_96 + 'A') */
118 /* Right half of ISO 8859-2 */
119 #define LEADING_BYTE_LATIN_ISO8859_2 101 /* (CHARSET_ID_OFFSET_96 + 'B') */
121 /* Right half of ISO 8859-3 */
122 #define LEADING_BYTE_LATIN_ISO8859_3 109 /* (CHARSET_ID_OFFSET_96 + 'C') */
124 /* Right half of ISO 8859-4 */
125 #define LEADING_BYTE_LATIN_ISO8859_4 110 /* (CHARSET_ID_OFFSET_96 + 'D') */
127 /* Right half of ISO 8859-7 */
128 #define LEADING_BYTE_GREEK_ISO8859_7 126 /* (CHARSET_ID_OFFSET_96 + 'F') */
130 /* Right half of ISO 8859-6 */
131 #define LEADING_BYTE_ARABIC_ISO8859_6 127 /* (CHARSET_ID_OFFSET_96 + 'G') */
133 /* Right half of ISO 8859-8 */
134 #define LEADING_BYTE_HEBREW_ISO8859_8 138 /* (CHARSET_ID_OFFSET_96 + 'H') */
136 /* Right half of ISO 8859-5 */
137 #define LEADING_BYTE_CYRILLIC_ISO8859_5 144 /* (CHARSET_ID_OFFSET_96 + 'L') */
139 /* Right half of ISO 8859-9 */
140 #define LEADING_BYTE_LATIN_ISO8859_9 148 /* (CHARSET_ID_OFFSET_96 + 'M') */
143 #define LEADING_BYTE_THAI_TIS620 166 /* (CHARSET_ID_OFFSET_96 + 'T') */
146 /* #define CHARSET_ID_OFFSET_94x94 (CHARSET_ID_OFFSET_96 + 80) */
149 /* #define MIN_LEADING_BYTE_PRIVATE_2 ('0' + CHARSET_ID_OFFSET_94x94) */
150 /* #define MAX_LEADING_BYTE_PRIVATE_2 ('?' + CHARSET_ID_OFFSET_94x94) */
152 /* Japanese JIS X0208-1978 2/4 2/{(8),9,10,11} 4/0 (@) */
153 #define LEADING_BYTE_JAPANESE_JISX0208_1978 42
155 /* Chinese Hanzi GB2312-1980 2/4 2/{(8),9,10,11} 4/1 (A) */
156 #define LEADING_BYTE_CHINESE_GB2312 58
158 /* Japanese JIS X0208-1983 2/4 2/{(8),9,10,11} 4/2 (B) */
159 #define LEADING_BYTE_JAPANESE_JISX0208 87
161 /* Hangul KS C5601-1987 2/4 2/{8,9,10,11} 4/3 (C) */
162 #define LEADING_BYTE_KOREAN_KSC5601 149
164 /* Japanese JIS X0212-1990 2/4 2/{8,9,10,11} 4/4 (D) */
165 #define LEADING_BYTE_JAPANESE_JISX0212 159
167 /* CCITT Extended GB 2/4 2/{8,9,10,11} 4/5 (E) */
168 #define LEADING_BYTE_CHINESE_CCITT_GB 165
170 /* Chinese CNS11643 Set 1 2/4 2/{8,9,10,11} 4/7 (G) */
171 #define LEADING_BYTE_CHINESE_CNS11643_1 171
173 /* Chinese CNS11643 Set 2 2/4 2/{8,9,10,11} 4/8 (H) */
174 #define LEADING_BYTE_CHINESE_CNS11643_2 172
176 /* Chinese CNS11643 Set 3 2/4 2/{8,9,10,11} 4/9 (I) */
177 #define LEADING_BYTE_CHINESE_CNS11643_3 183
179 /* Chinese CNS11643 Set 4 2/4 2/{8,9,10,11} 4/10 (J) */
180 #define LEADING_BYTE_CHINESE_CNS11643_4 184
182 /* Chinese CNS11643 Set 5 2/4 2/{8,9,10,11} 4/11 (K) */
183 #define LEADING_BYTE_CHINESE_CNS11643_5 185
185 /* Chinese CNS11643 Set 6 2/4 2/{8,9,10,11} 4/12 (L) */
186 #define LEADING_BYTE_CHINESE_CNS11643_6 186
188 /* Chinese CNS11643 Set 7 2/4 2/{8,9,10,11} 4/13 (M) */
189 #define LEADING_BYTE_CHINESE_CNS11643_7 187
191 /* DPRK Hangul KPS 9566-1997 2/4 2/{8,9,10,11} 4/14 (N) */
192 #define LEADING_BYTE_KOREAN_KPS9566 202
195 #define NUM_LEADING_BYTES (80 * 3 - MIN_LEADING_BYTE)
198 /************************************************************************/
199 /* Information about a particular character set */
200 /************************************************************************/
204 struct lcrecord_header header;
208 Lisp_Object doc_string, registry, short_name, long_name;
210 Lisp_Object reverse_direction_charset;
212 Lisp_Object ccl_program;
214 /* Final byte of this character set in ISO2022 designating escape sequence */
217 /* Number of columns a character in this charset takes up, on TTY
218 devices. Not used for X devices. */
219 unsigned int columns;
221 /* Direction of this character set */
222 unsigned int direction;
224 /* Type of this character set (94, 96, 94x94, 96x96) */
227 /* Number of bytes used in encoding of this character set (1 or 2) */
228 unsigned int dimension;
230 /* Number of chars in each dimension (usually 94 or 96) */
233 /* Which half of font to be used to display this character set */
234 unsigned int graphic;
236 /* Byte->character mapping table */
237 Lisp_Object decoding_table;
239 /* Range of character code */
240 Emchar ucs_min, ucs_max;
242 /* Offset for external code */
245 /* Offset for each byte */
249 DECLARE_LRECORD (charset, struct Lisp_Charset);
250 #define XCHARSET(x) XRECORD (x, charset, struct Lisp_Charset)
251 #define XSETCHARSET(x, p) XSETRECORD (x, p, charset)
252 #define CHARSETP(x) RECORDP (x, charset)
253 #define GC_CHARSETP(x) GC_RECORDP (x, charset)
254 #define CHECK_CHARSET(x) CHECK_RECORD (x, charset)
255 #define CONCHECK_CHARSET(x) CONCHECK_RECORD (x, charset)
257 #define CHARSET_TYPE_94 0 /* This charset includes 94 characters. */
258 #define CHARSET_TYPE_94X94 1 /* This charset includes 94x94 characters. */
259 #define CHARSET_TYPE_96 2 /* This charset includes 96 characters. */
260 #define CHARSET_TYPE_96X96 3 /* This charset includes 96x96 characters. */
261 #define CHARSET_TYPE_128 4 /* This charset includes 128 characters. */
262 #define CHARSET_TYPE_128X128 5 /* This charset includes 128x128 characters. */
263 #define CHARSET_TYPE_256 6 /* This charset includes 256 characters. */
264 #define CHARSET_TYPE_256X256 7 /* This charset includes 256x256 characters. */
266 #define CHARSET_LEFT_TO_RIGHT 0
267 #define CHARSET_RIGHT_TO_LEFT 1
269 /* Leading byte and id have been regrouped. -- OG */
270 #define CHARSET_ID(cs) ((cs)->id)
271 #define CHARSET_LEADING_BYTE(cs) (CHARSET_ID(cs))
272 #define CHARSET_NAME(cs) ((cs)->name)
273 #define CHARSET_SHORT_NAME(cs) ((cs)->short_name)
274 #define CHARSET_LONG_NAME(cs) ((cs)->long_name)
275 #define CHARSET_COLUMNS(cs) ((cs)->columns)
276 #define CHARSET_GRAPHIC(cs) ((cs)->graphic)
277 #define CHARSET_TYPE(cs) ((cs)->type)
278 #define CHARSET_DIRECTION(cs) ((cs)->direction)
279 #define CHARSET_FINAL(cs) ((cs)->final)
280 #define CHARSET_DOC_STRING(cs) ((cs)->doc_string)
281 #define CHARSET_REGISTRY(cs) ((cs)->registry)
282 #define CHARSET_CCL_PROGRAM(cs) ((cs)->ccl_program)
283 #define CHARSET_DIMENSION(cs) ((cs)->dimension)
284 #define CHARSET_CHARS(cs) ((cs)->chars)
285 #define CHARSET_REVERSE_DIRECTION_CHARSET(cs) ((cs)->reverse_direction_charset)
286 #define CHARSET_DECODING_TABLE(cs) ((cs)->decoding_table)
287 #define CHARSET_UCS_MIN(cs) ((cs)->ucs_min)
288 #define CHARSET_UCS_MAX(cs) ((cs)->ucs_max)
289 #define CHARSET_CODE_OFFSET(cs) ((cs)->code_offset)
290 #define CHARSET_BYTE_OFFSET(cs) ((cs)->byte_offset)
293 #define XCHARSET_ID(cs) CHARSET_ID (XCHARSET (cs))
294 #define XCHARSET_NAME(cs) CHARSET_NAME (XCHARSET (cs))
295 #define XCHARSET_SHORT_NAME(cs) CHARSET_SHORT_NAME (XCHARSET (cs))
296 #define XCHARSET_LONG_NAME(cs) CHARSET_LONG_NAME (XCHARSET (cs))
297 #define XCHARSET_GRAPHIC(cs) CHARSET_GRAPHIC (XCHARSET (cs))
298 #define XCHARSET_TYPE(cs) CHARSET_TYPE (XCHARSET (cs))
299 #define XCHARSET_DIRECTION(cs) CHARSET_DIRECTION (XCHARSET (cs))
300 #define XCHARSET_FINAL(cs) CHARSET_FINAL (XCHARSET (cs))
301 #define XCHARSET_DOC_STRING(cs) CHARSET_DOC_STRING (XCHARSET (cs))
302 #define XCHARSET_REGISTRY(cs) CHARSET_REGISTRY (XCHARSET (cs))
303 #define XCHARSET_LEADING_BYTE(cs) CHARSET_LEADING_BYTE (XCHARSET (cs))
304 #define XCHARSET_CCL_PROGRAM(cs) CHARSET_CCL_PROGRAM (XCHARSET (cs))
305 #define XCHARSET_DIMENSION(cs) CHARSET_DIMENSION (XCHARSET (cs))
306 #define XCHARSET_CHARS(cs) CHARSET_CHARS (XCHARSET (cs))
307 #define XCHARSET_REVERSE_DIRECTION_CHARSET(cs) \
308 CHARSET_REVERSE_DIRECTION_CHARSET (XCHARSET (cs))
309 #define XCHARSET_DECODING_TABLE(cs) CHARSET_DECODING_TABLE(XCHARSET(cs))
310 #define XCHARSET_UCS_MIN(cs) CHARSET_UCS_MIN(XCHARSET(cs))
311 #define XCHARSET_UCS_MAX(cs) CHARSET_UCS_MAX(XCHARSET(cs))
312 #define XCHARSET_CODE_OFFSET(cs) CHARSET_CODE_OFFSET(XCHARSET(cs))
313 #define XCHARSET_BYTE_OFFSET(cs) CHARSET_BYTE_OFFSET(XCHARSET(cs))
315 /* Table of charsets indexed by (leading byte - 128). */
316 extern Lisp_Object charset_by_leading_byte[NUM_LEADING_BYTES];
318 /* Table of charsets indexed by type/final-byte. */
319 extern Lisp_Object charset_by_attributes[4][128];
321 #ifdef ERROR_CHECK_TYPECHECK
322 /* int not Bufbyte even though that is the actual type of a leading byte.
323 This way, out-ot-range values will get caught rather than automatically
325 INLINE Lisp_Object CHARSET_BY_LEADING_BYTE (Charset_ID lb);
327 CHARSET_BY_LEADING_BYTE (Charset_ID lb)
329 assert (lb >= MIN_LEADING_BYTE &&
330 lb < (MIN_LEADING_BYTE + NUM_LEADING_BYTES));
331 return charset_by_leading_byte[lb - MIN_LEADING_BYTE];
336 #define CHARSET_BY_LEADING_BYTE(lb) \
337 (charset_by_leading_byte[(lb) - MIN_LEADING_BYTE])
341 #define CHARSET_BY_ATTRIBUTES(type, final, dir) \
342 (charset_by_attributes[type][final])
345 /************************************************************************/
346 /* Dealing with characters */
347 /************************************************************************/
349 #define MAX_CHAR_BASIC_LATIN 0x007F
351 #define MIN_CHAR_GREEK 0x0370
352 #define MAX_CHAR_GREEK 0x03CF
354 #define MIN_CHAR_CYRILLIC 0x0400
355 #define MAX_CHAR_CYRILLIC 0x045F
357 #define MIN_CHAR_HEBREW 0x0590
358 #define MAX_CHAR_HEBREW 0x05EF
360 #define MIN_CHAR_THAI 0x0E00
361 #define MAX_CHAR_THAI 0x0E5F
363 #define MIN_CHAR_HIRAGANA 0x3041
364 #define MAX_CHAR_HIRAGANA 0x3093
366 #define MIN_CHAR_KATAKANA 0x30A1
367 #define MAX_CHAR_KATAKANA 0x30F6
369 #define MIN_CHAR_HALFWIDTH_KATAKANA 0xFF61
370 #define MAX_CHAR_HALFWIDTH_KATAKANA 0xFF9F
372 #define MIN_CHAR_OBS_94x94 0xE00000
373 #define MAX_CHAR_OBS_94x94 (0xE00000 + 94 * 94 * 14 - 1)
375 #define MIN_CHAR_94 0xE90940
376 #define MAX_CHAR_94 (MIN_CHAR_94 + 94 * 80 - 1)
377 #define MIN_CHAR_96 (MIN_CHAR_94 + 94 * 80)
378 #define MAX_CHAR_96 (MIN_CHAR_96 + 96 * 80 - 1)
380 #define MIN_CHAR_94x94 0xE9F6C0
381 #define MAX_CHAR_94x94 (MIN_CHAR_94x94 + 94 * 94 * 80 - 1)
382 #define MIN_CHAR_96x96 0xF4C000
383 #define MAX_CHAR_96x96 (MIN_CHAR_96x96 + 96 * 96 * 80 - 1)
386 /* Return a character whose charset is CHARSET and position-codes
387 are C1 and C2. TYPE9N character ignores C2. */
389 INLINE Emchar MAKE_CHAR (Lisp_Object charset, int c1, int c2);
391 MAKE_CHAR (Lisp_Object charset, int c1, int c2)
393 Lisp_Object decoding_table = XCHARSET_DECODING_TABLE (charset);
397 if (!EQ (decoding_table, Qnil)
398 && (0 <= (idx = c1 - XCHARSET_BYTE_OFFSET (charset)))
399 && (idx < XVECTOR_LENGTH (decoding_table))
400 && !EQ (ch = XVECTOR_DATA(decoding_table)[idx], Qnil))
404 if ((0 <= (idx = c2 - XCHARSET_BYTE_OFFSET (charset)))
405 && (idx < XVECTOR_LENGTH (ch))
406 && !EQ (ch = XVECTOR_DATA(ch)[idx], Qnil))
412 if (EQ (charset, Vcharset_katakana_jisx0201))
414 return c1 + MIN_CHAR_HALFWIDTH_KATAKANA - 33;
416 /* return MIN_CHAR_94 + ('I' - '0') * 94 + (c1 - 33); */
418 else if (XCHARSET_UCS_MAX (charset))
421 = (XCHARSET_DIMENSION (charset) == 1
423 c1 - XCHARSET_BYTE_OFFSET (charset)
425 (c1 - XCHARSET_BYTE_OFFSET (charset)) * XCHARSET_CHARS (charset)
426 + c2 - XCHARSET_BYTE_OFFSET (charset))
427 - XCHARSET_CODE_OFFSET (charset) + XCHARSET_UCS_MIN (charset);
428 if ((code < XCHARSET_UCS_MIN (charset))
429 || (XCHARSET_UCS_MAX (charset) < code))
430 signal_simple_error ("Arguments makes invalid character",
434 else if (XCHARSET_DIMENSION (charset) == 1)
436 switch (XCHARSET_CHARS (charset))
440 + (XCHARSET_FINAL (charset) - '0') * 94 + (c1 - 33);
443 + (XCHARSET_FINAL (charset) - '0') * 96 + (c1 - 32);
450 switch (XCHARSET_CHARS (charset))
453 return MIN_CHAR_94x94
454 + (XCHARSET_FINAL (charset) - '0') * 94 * 94
455 + (c1 - 33) * 94 + (c2 - 33);
457 return MIN_CHAR_96x96
458 + (XCHARSET_FINAL (charset) - '0') * 96 * 96
459 + (c1 - 32) * 96 + (c2 - 32);
466 extern Lisp_Object Vcharacter_attribute_table;
468 Lisp_Object range_charset_code_point (Lisp_Object charset, Emchar ch);
469 Lisp_Object charset_code_point (Lisp_Object charset, Emchar ch);
471 extern Lisp_Object Vdefault_coded_charset_priority_list;
472 EXFUN (Ffind_charset, 1);
474 INLINE Lisp_Object SPLIT_CHAR (Emchar c);
476 SPLIT_CHAR (Emchar c)
478 Lisp_Object cdef = get_char_code_table (c, Vcharacter_attribute_table);
480 if (!EQ (cdef, Qnil))
482 Lisp_Object charsets = Vdefault_coded_charset_priority_list;
485 while (!EQ (charsets, Qnil))
487 Lisp_Object charset = Ffind_charset (Fcar (charsets));
489 if (!EQ (charset, Qnil))
491 if (!EQ (field = Fcdr (Fassq (charset, cdef)), Qnil) ||
492 !EQ (field = range_charset_code_point (charset, c), Qnil))
493 return Fcons (charset, field);
495 charsets = Fcdr (charsets);
499 /* otherwise --- maybe for bootstrap */
500 if (c < MIN_CHAR_OBS_94x94)
502 if (c <= MAX_CHAR_BASIC_LATIN)
504 return list2 (Vcharset_ascii, make_int (c));
508 return list2 (Vcharset_control_1, make_int (c & 0x7F));
512 return list2 (Vcharset_latin_iso8859_1, make_int (c & 0x7F));
514 else if ((MIN_CHAR_GREEK <= c) && (c <= MAX_CHAR_GREEK))
516 return list2 (Vcharset_greek_iso8859_7,
517 make_int (c - MIN_CHAR_GREEK + 0x20));
519 else if ((MIN_CHAR_CYRILLIC <= c) && (c <= MAX_CHAR_CYRILLIC))
521 return list2 (Vcharset_cyrillic_iso8859_5,
522 make_int (c - MIN_CHAR_CYRILLIC + 0x20));
524 else if ((MIN_CHAR_HEBREW <= c) && (c <= MAX_CHAR_HEBREW))
526 return list2 (Vcharset_hebrew_iso8859_8,
527 make_int (c - MIN_CHAR_HEBREW + 0x20));
529 else if ((MIN_CHAR_THAI <= c) && (c <= MAX_CHAR_THAI))
531 return list2 (Vcharset_thai_tis620,
532 make_int (c - MIN_CHAR_THAI + 0x20));
534 else if ((MIN_CHAR_HALFWIDTH_KATAKANA <= c)
535 && (c <= MAX_CHAR_HALFWIDTH_KATAKANA))
537 return list2 (Vcharset_katakana_jisx0201,
538 make_int (c - MIN_CHAR_HALFWIDTH_KATAKANA + 33));
542 return list3 (Vcharset_ucs_bmp,
543 make_int (c >> 8), make_int (c & 0xff));
546 else if (c <= MAX_CHAR_OBS_94x94)
548 return list3 (CHARSET_BY_ATTRIBUTES
550 ((c - MIN_CHAR_OBS_94x94) / (94 * 94)) + '@',
551 CHARSET_LEFT_TO_RIGHT),
552 make_int ((((c - MIN_CHAR_OBS_94x94) / 94) % 94) + 33),
553 make_int (((c - MIN_CHAR_OBS_94x94) % 94) + 33));
555 else if (c <= MAX_CHAR_94)
557 return list2 (CHARSET_BY_ATTRIBUTES (CHARSET_TYPE_94,
558 ((c - MIN_CHAR_94) / 94) + '0',
559 CHARSET_LEFT_TO_RIGHT),
560 make_int (((c - MIN_CHAR_94) % 94) + 33));
562 else if (c <= MAX_CHAR_96)
564 return list2 (CHARSET_BY_ATTRIBUTES (CHARSET_TYPE_96,
565 ((c - MIN_CHAR_96) / 96) + '0',
566 CHARSET_LEFT_TO_RIGHT),
567 make_int (((c - MIN_CHAR_96) % 96) + 32));
569 else if (c <= MAX_CHAR_94x94)
571 return list3 (CHARSET_BY_ATTRIBUTES
573 ((c - MIN_CHAR_94x94) / (94 * 94)) + '0',
574 CHARSET_LEFT_TO_RIGHT),
575 make_int ((((c - MIN_CHAR_94x94) / 94) % 94) + 33),
576 make_int (((c - MIN_CHAR_94x94) % 94) + 33));
578 else if (c <= MAX_CHAR_96x96)
580 return list3 (CHARSET_BY_ATTRIBUTES
582 ((c - MIN_CHAR_96x96) / (96 * 96)) + '0',
583 CHARSET_LEFT_TO_RIGHT),
584 make_int ((((c - MIN_CHAR_96x96) / 96) % 96) + 32),
585 make_int (((c - MIN_CHAR_96x96) % 96) + 32));
593 INLINE void breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2);
595 breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2)
597 Lisp_Object ret = SPLIT_CHAR (c);
599 *charset = Fcar (ret);
601 if (INTP (Fcar (ret)))
603 *c1 = XINT (Fcar (ret));
605 if (INTP (Fcar (ret)))
606 *c2 = XINT (Fcar (ret));
616 #define BREAKUP_CHAR(ch, charset, b1, b2) \
617 breakup_char_1 (ch, &(charset), &(b1), &(b2))
619 INLINE Lisp_Object CHAR_CHARSET (Emchar ch);
621 CHAR_CHARSET (Emchar ch)
626 BREAKUP_CHAR(ch, charset, b1, b2);
630 #define CHAR_CHARSET_ID(c) (XCHARSET_ID(CHAR_CHARSET(c)))
631 #define CHAR_COLUMNS(c) (CHARSET_COLUMNS(XCHARSET(CHAR_CHARSET(c))))
634 /************************************************************************/
635 /* Exported functions */
636 /************************************************************************/
638 EXFUN (Fget_charset, 1);
640 extern Lisp_Object Vcharset_chinese_big5_1;
641 extern Lisp_Object Vcharset_chinese_big5_2;
642 extern Lisp_Object Vcharset_japanese_jisx0208;
643 extern Lisp_Object Vcharset_japanese_jisx0212;
645 #endif /* _XEMACS_CHAR_UCS_H */