(Fmake_char): Fix problem of 256-set.
[chise/xemacs-chise.git-] / src / char-ucs.h
1 /* Header for UCS-4 character representation.
2    Copyright (C) 1999 Electrotechnical Laboratory, JAPAN.
3    Licensed to the Free Software Foundation.
4
5 This file is part of XEmacs.
6
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
10 later version.
11
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
15 for more details.
16
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.  */
21
22 /* Rewritten by MORIOKA Tomohiko <tomo@m17n.org>. */
23
24 #ifndef _XEMACS_CHAR_UCS_H
25 #define _XEMACS_CHAR_UCS_H
26
27 #define valid_char_p(ch) 1
28
29 #define CHAR_ASCII_P(ch) ((ch) <= 0x7F)
30
31 \f
32 /************************************************************************/
33 /*                    Definition of leading bytes                       */
34 /************************************************************************/
35
36 typedef int Charset_ID;
37
38 #define MIN_LEADING_BYTE                0x80
39
40 #define LEADING_BYTE_UCS_BMP            0x80
41 #define LEADING_BYTE_CONTROL_1          0x81 /* represent normal 80-9F */
42
43
44 #define CHARSET_ID_OFFSET_94            0x60
45
46 #define MIN_CHARSET_ID_PRIVATE_94       (CHARSET_ID_OFFSET_94 + '0')
47 #define MAX_CHARSET_ID_PRIVATE_94       (CHARSET_ID_OFFSET_94 + '?')
48
49 /* ISO 646 IRV */
50 #define LEADING_BYTE_ASCII              (CHARSET_ID_OFFSET_94 + 'B')
51
52 /* Right half of JIS X0201-1976 */
53 #define LEADING_BYTE_KATAKANA_JISX0201  (CHARSET_ID_OFFSET_94 + 'I')
54
55 /* Left  half of JIS X0201-1976 */
56 #define LEADING_BYTE_LATIN_JISX0201     (CHARSET_ID_OFFSET_94 + 'J')
57
58
59 #define CHARSET_ID_OFFSET_96            0x70
60
61 /* Right half of ISO 8859-1 */
62 #define LEADING_BYTE_LATIN_ISO8859_1    (CHARSET_ID_OFFSET_96 + 'A')
63
64 /* Right half of ISO 8859-2 */
65 #define LEADING_BYTE_LATIN_ISO8859_2    (CHARSET_ID_OFFSET_96 + 'B')
66
67 /* Right half of ISO 8859-3 */
68 #define LEADING_BYTE_LATIN_ISO8859_3    (CHARSET_ID_OFFSET_96 + 'C')
69
70 /* Right half of ISO 8859-4 */
71 #define LEADING_BYTE_LATIN_ISO8859_4    (CHARSET_ID_OFFSET_96 + 'D')
72
73 /* Right half of ISO 8859-7 */
74 #define LEADING_BYTE_GREEK_ISO8859_7    (CHARSET_ID_OFFSET_96 + 'F')
75
76 /* Right half of ISO 8859-6 */
77 #define LEADING_BYTE_ARABIC_ISO8859_6   (CHARSET_ID_OFFSET_96 + 'G')
78
79 /* Right half of ISO 8859-8 */
80 #define LEADING_BYTE_HEBREW_ISO8859_8   (CHARSET_ID_OFFSET_96 + 'H')
81
82 /* Right half of ISO 8859-5 */
83 #define LEADING_BYTE_CYRILLIC_ISO8859_5 (CHARSET_ID_OFFSET_96 + 'L')
84
85 /* Right half of ISO 8859-9 */
86 #define LEADING_BYTE_LATIN_ISO8859_9    (CHARSET_ID_OFFSET_96 + 'M')
87
88 /* TIS620-2533 */
89 #define LEADING_BYTE_THAI_TIS620        (CHARSET_ID_OFFSET_96 + 'T')
90
91
92 #define MIN_LEADING_BYTE_PRIVATE_1      0xD0
93 #define MAX_LEADING_BYTE_PRIVATE_1      0xDF
94
95
96 #define CHARSET_ID_OFFSET_94x94         0xB0
97
98 /* Big5 Level 1 */
99 #define LEADING_BYTE_CHINESE_BIG5_1     ('0' + CHARSET_ID_OFFSET_94x94)
100
101 /* Big5 Level 2 */
102 #define LEADING_BYTE_CHINESE_BIG5_2     ('1' + CHARSET_ID_OFFSET_94x94)
103
104 #define MIN_LEADING_BYTE_PRIVATE_2      ('0' + CHARSET_ID_OFFSET_94x94)
105 #define MAX_LEADING_BYTE_PRIVATE_2      ('?' + CHARSET_ID_OFFSET_94x94)
106
107 /* Japanese JIS X0208-1978 */
108 #define LEADING_BYTE_JAPANESE_JISX0208_1978 \
109                                         ('@' + CHARSET_ID_OFFSET_94x94)
110
111 /* Chinese Hanzi GB2312-1980 */
112 #define LEADING_BYTE_CHINESE_GB2312     ('A' + CHARSET_ID_OFFSET_94x94)
113
114 /* Japanese JIS X0208-1983 */
115 #define LEADING_BYTE_JAPANESE_JISX0208  ('B' + CHARSET_ID_OFFSET_94x94)
116
117 /* Hangul KS C5601-1987 */
118 #define LEADING_BYTE_KOREAN_KSC5601     ('C' + CHARSET_ID_OFFSET_94x94)
119
120 /* Japanese JIS X0212-1990 */
121 #define LEADING_BYTE_JAPANESE_JISX0212  ('D' + CHARSET_ID_OFFSET_94x94)
122
123 /* CCITT Extended GB */
124 #define LEADING_BYTE_CHINESE_CCITT_GB   ('E' + CHARSET_ID_OFFSET_94x94)
125
126 /* Chinese CNS11643 Set 1 */
127 #define LEADING_BYTE_CHINESE_CNS11643_1 ('G' + CHARSET_ID_OFFSET_94x94)
128
129 /* Chinese CNS11643 Set 2 */
130 #define LEADING_BYTE_CHINESE_CNS11643_2 ('H' + CHARSET_ID_OFFSET_94x94)
131
132 /* Chinese CNS11643 Set 3 */
133 #define LEADING_BYTE_CHINESE_CNS11643_3 ('I' + CHARSET_ID_OFFSET_94x94)
134
135 /* Chinese CNS11643 Set 4 */
136 #define LEADING_BYTE_CHINESE_CNS11643_4 ('J' + CHARSET_ID_OFFSET_94x94)
137
138 /* Chinese CNS11643 Set 5 */
139 #define LEADING_BYTE_CHINESE_CNS11643_5 ('K' + CHARSET_ID_OFFSET_94x94)
140
141 /* Chinese CNS11643 Set 6 */
142 #define LEADING_BYTE_CHINESE_CNS11643_6 ('L' + CHARSET_ID_OFFSET_94x94)
143
144 /* Chinese CNS11643 Set 7 */
145 #define LEADING_BYTE_CHINESE_CNS11643_7 ('M' + CHARSET_ID_OFFSET_94x94)
146
147 /* DPRK Hangul KPS 9566-1997 */
148 #define LEADING_BYTE_KOREAN_KPS9566     ('N' + CHARSET_ID_OFFSET_94x94)
149
150 #define MIN_LEADING_BYTE_OFFICIAL_2     LEADING_BYTE_JAPANESE_JISX0208_1978
151 #define MAX_LEADING_BYTE_OFFICIAL_2     LEADING_BYTE_KOREAN_KPS9566
152
153 #define NUM_LEADING_BYTES 256
154
155 \f
156 /************************************************************************/
157 /*            Information about a particular character set              */
158 /************************************************************************/
159
160 struct Lisp_Charset
161 {
162   struct lcrecord_header header;
163
164   int id;
165   Lisp_Object name;
166   Lisp_Object doc_string, registry, short_name, long_name;
167
168   Lisp_Object reverse_direction_charset;
169
170   Lisp_Object ccl_program;
171
172   /* Final byte of this character set in ISO2022 designating escape sequence */
173   Bufbyte final;
174
175   /* Number of bytes (1 - 4) required in the internal representation
176      for characters in this character set.  This is *not* the
177      same as the dimension of the character set). */
178   unsigned int rep_bytes;
179
180   /* Number of columns a character in this charset takes up, on TTY
181      devices.  Not used for X devices. */
182   unsigned int columns;
183
184   /* Direction of this character set */
185   unsigned int direction;
186
187   /* Type of this character set (94, 96, 94x94, 96x96) */
188   unsigned int type;
189
190   /* Number of bytes used in encoding of this character set (1 or 2) */
191   unsigned int dimension;
192
193   /* Number of chars in each dimension (usually 94 or 96) */
194   unsigned int chars;
195
196   /* Which half of font to be used to display this character set */
197   unsigned int graphic;
198 };
199
200 DECLARE_LRECORD (charset, struct Lisp_Charset);
201 #define XCHARSET(x) XRECORD (x, charset, struct Lisp_Charset)
202 #define XSETCHARSET(x, p) XSETRECORD (x, p, charset)
203 #define CHARSETP(x) RECORDP (x, charset)
204 #define GC_CHARSETP(x) GC_RECORDP (x, charset)
205 #define CHECK_CHARSET(x) CHECK_RECORD (x, charset)
206 #define CONCHECK_CHARSET(x) CONCHECK_RECORD (x, charset)
207
208 #define CHARSET_TYPE_94      0 /* This charset includes 94    characters. */
209 #define CHARSET_TYPE_96      1 /* This charset includes 96    characters. */
210 #define CHARSET_TYPE_94X94   2 /* This charset includes 94x94 characters. */
211 #define CHARSET_TYPE_96X96   3 /* This charset includes 96x96 characters. */
212 #define CHARSET_TYPE_128X128 4 /* This charset includes 128x128 characters. */
213 #define CHARSET_TYPE_256X256 5 /* This charset includes 256x256 characters. */
214
215 #define CHARSET_LEFT_TO_RIGHT   0
216 #define CHARSET_RIGHT_TO_LEFT   1
217
218 /* Leading byte and id have been regrouped. -- OG */
219 #define CHARSET_ID(cs)           ((cs)->id)
220 #define CHARSET_LEADING_BYTE(cs) ((Bufbyte)(CHARSET_ID(cs)))
221 #define CHARSET_NAME(cs)         ((cs)->name)
222 #define CHARSET_SHORT_NAME(cs)   ((cs)->short_name)
223 #define CHARSET_LONG_NAME(cs)    ((cs)->long_name)
224 #define CHARSET_REP_BYTES(cs)    ((cs)->rep_bytes)
225 #define CHARSET_COLUMNS(cs)      ((cs)->columns)
226 #define CHARSET_GRAPHIC(cs)      ((cs)->graphic)
227 #define CHARSET_TYPE(cs)         ((cs)->type)
228 #define CHARSET_DIRECTION(cs)    ((cs)->direction)
229 #define CHARSET_FINAL(cs)        ((cs)->final)
230 #define CHARSET_DOC_STRING(cs)   ((cs)->doc_string)
231 #define CHARSET_REGISTRY(cs)     ((cs)->registry)
232 #define CHARSET_CCL_PROGRAM(cs)  ((cs)->ccl_program)
233 #define CHARSET_DIMENSION(cs)    ((cs)->dimension)
234 #define CHARSET_CHARS(cs)        ((cs)->chars)
235 #define CHARSET_REVERSE_DIRECTION_CHARSET(cs) ((cs)->reverse_direction_charset)
236
237
238 #define XCHARSET_ID(cs)           CHARSET_ID           (XCHARSET (cs))
239 #define XCHARSET_NAME(cs)         CHARSET_NAME         (XCHARSET (cs))
240 #define XCHARSET_SHORT_NAME(cs)   CHARSET_SHORT_NAME   (XCHARSET (cs))
241 #define XCHARSET_LONG_NAME(cs)    CHARSET_LONG_NAME    (XCHARSET (cs))
242 #define XCHARSET_REP_BYTES(cs)    CHARSET_REP_BYTES    (XCHARSET (cs))
243 #define XCHARSET_COLUMNS(cs)      CHARSET_COLUMNS      (XCHARSET (cs))
244 #define XCHARSET_GRAPHIC(cs)      CHARSET_GRAPHIC      (XCHARSET (cs))
245 #define XCHARSET_TYPE(cs)         CHARSET_TYPE         (XCHARSET (cs))
246 #define XCHARSET_DIRECTION(cs)    CHARSET_DIRECTION    (XCHARSET (cs))
247 #define XCHARSET_FINAL(cs)        CHARSET_FINAL        (XCHARSET (cs))
248 #define XCHARSET_DOC_STRING(cs)   CHARSET_DOC_STRING   (XCHARSET (cs))
249 #define XCHARSET_REGISTRY(cs)     CHARSET_REGISTRY     (XCHARSET (cs))
250 #define XCHARSET_LEADING_BYTE(cs) CHARSET_LEADING_BYTE (XCHARSET (cs))
251 #define XCHARSET_CCL_PROGRAM(cs)  CHARSET_CCL_PROGRAM  (XCHARSET (cs))
252 #define XCHARSET_DIMENSION(cs)    CHARSET_DIMENSION    (XCHARSET (cs))
253 #define XCHARSET_CHARS(cs)        CHARSET_CHARS        (XCHARSET (cs))
254 #define XCHARSET_REVERSE_DIRECTION_CHARSET(cs) \
255   CHARSET_REVERSE_DIRECTION_CHARSET (XCHARSET (cs))
256
257 /* Table of charsets indexed by (leading byte - 128). */
258 extern Lisp_Object charset_by_leading_byte[NUM_LEADING_BYTES];
259
260 /* Table of charsets indexed by type/final-byte. */
261 extern Lisp_Object charset_by_attributes[4][128];
262
263 #ifdef ERROR_CHECK_TYPECHECK
264 /* int not Bufbyte even though that is the actual type of a leading byte.
265    This way, out-ot-range values will get caught rather than automatically
266    truncated. */
267 INLINE Lisp_Object CHARSET_BY_LEADING_BYTE (Charset_ID lb);
268 INLINE Lisp_Object
269 CHARSET_BY_LEADING_BYTE (Charset_ID lb)
270 {
271   assert (lb >= MIN_LEADING_BYTE &&
272           lb < (MIN_LEADING_BYTE + NUM_LEADING_BYTES));
273   return charset_by_leading_byte[lb - MIN_LEADING_BYTE];
274 }
275
276 #else
277
278 #define CHARSET_BY_LEADING_BYTE(lb) \
279   (charset_by_leading_byte[(lb) - MIN_LEADING_BYTE])
280
281 #endif
282
283 #define CHARSET_BY_ATTRIBUTES(type, final, dir) \
284   (charset_by_attributes[type][final])
285
286 \f
287 /************************************************************************/
288 /*                        Dealing with characters                       */
289 /************************************************************************/
290
291 #define MAX_CHAR_BASIC_LATIN    0x007F
292
293 #define MIN_CHAR_GREEK          0x0370
294 #define MAX_CHAR_GREEK          0x03CF
295
296 #define MIN_CHAR_CYRILLIC       0x0400
297 #define MAX_CHAR_CYRILLIC       0x045F
298
299 #define MIN_CHAR_HEBREW         0x0590
300 #define MAX_CHAR_HEBREW         0x05EF
301
302 #define MIN_CHAR_THAI           0x0E00
303 #define MAX_CHAR_THAI           0x0E5F
304
305 #define MIN_CHAR_HALFWIDTH_KATAKANA     0xFF60
306 #define MAX_CHAR_HALFWIDTH_KATAKANA     0xFF9F
307
308 #define MIN_CHAR_94             0xE90940
309 #define MAX_CHAR_94             (MIN_CHAR_94 + 94 * 80 - 1)
310 #define MIN_CHAR_96             (MIN_CHAR_94 + 94 * 80)
311 #define MAX_CHAR_96             (MIN_CHAR_96 + 96 * 80 - 1)
312
313 #define MIN_CHAR_94x94          0xE9F6C0
314 #define MAX_CHAR_94x94          (MIN_CHAR_94x94 + 94 * 94 * 80 - 1)
315 #define MIN_CHAR_96x96          0xF4C000
316 #define MAX_CHAR_96x96          (MIN_CHAR_96x96 + 96 * 96 * 80 - 1)
317
318 extern Lisp_Object Vcharset_ucs_bmp;
319
320 /* Return a character whose charset is CHARSET and position-codes
321    are C1 and C2.  TYPE9N character ignores C2. */
322
323 INLINE Emchar MAKE_CHAR (Lisp_Object charset, int c1, int c2);
324 INLINE Emchar
325 MAKE_CHAR (Lisp_Object charset, int c1, int c2)
326 {
327   if (EQ (charset, Vcharset_ascii))
328     return c1;
329   else if (EQ (charset, Vcharset_control_1))
330     return c1 | 0x80;
331   else if (EQ (charset, Vcharset_ucs_bmp))
332     return (c1 << 8) | c2;
333   else if (EQ (charset, Vcharset_latin_iso8859_1))
334     return c1 | 0x80;
335   else if (EQ (charset, Vcharset_greek_iso8859_7))
336     return c1 + MIN_CHAR_GREEK - 0x20;
337   else if (EQ (charset, Vcharset_cyrillic_iso8859_5))
338     return c1 + MIN_CHAR_CYRILLIC - 0x20;
339   else if (EQ (charset, Vcharset_hebrew_iso8859_8))
340     return c1 + MIN_CHAR_HEBREW - 0x20;
341   else if (EQ (charset, Vcharset_thai_tis620))
342     return c1 + MIN_CHAR_THAI - 0x20;
343   else if (EQ (charset, Vcharset_katakana_jisx0201))
344     if (c1 < 0x60)
345       return c1 + MIN_CHAR_HALFWIDTH_KATAKANA - 0x20;
346     else
347       return 32;
348   else if (XCHARSET_DIMENSION (charset) == 1)
349     {
350       switch (XCHARSET_CHARS (charset))
351         {
352         case 94:
353           return MIN_CHAR_94
354             + (XCHARSET_FINAL (charset) - '0') * 94 + (c1 - 33);
355         case 96:
356           return MIN_CHAR_96
357             + (XCHARSET_FINAL (charset) - '0') * 96 + (c1 - 32);
358         default:
359           abort ();
360         }
361     }
362   else
363     {
364       switch (XCHARSET_CHARS (charset))
365         {
366         case 94:
367           return MIN_CHAR_94x94
368             + (XCHARSET_FINAL (charset) - '0') * 94 * 94
369             + (c1 - 33) * 94 + (c2 - 33);
370         case 96:
371           return MIN_CHAR_96x96
372             + (XCHARSET_FINAL (charset) - '0') * 96 * 96
373             + (c1 - 32) * 96 + (c2 - 32);
374         default:
375           abort ();
376         }
377     }
378 }
379
380 extern Charset_ID    latin_a_char_to_charset[128];
381 extern unsigned char latin_a_char_to_byte1[128];
382 extern unsigned char latin_a_char_to_byte2[128];
383
384 INLINE void breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2);
385 INLINE void
386 breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2)
387 {
388   if (c <= MAX_CHAR_BASIC_LATIN)
389     {
390       *charset = Vcharset_ascii;
391       *c1 = c;
392       *c2 = 0;
393     }
394   else if (c < 0xA0)
395     {
396       *charset = Vcharset_control_1;
397       *c1 = c & 0x7f;
398       *c2 = 0;
399     }
400   else if (c <= 0xff)
401     {
402       *charset = Vcharset_latin_iso8859_1;
403       *c1 = c & 0x7f;
404       *c2 = 0;
405     }
406   else if (c <= 0x17f)
407     {
408       *charset
409         = CHARSET_BY_LEADING_BYTE (latin_a_char_to_charset[c - 0x100]);
410       *c1 = latin_a_char_to_byte1[c - 0x100];
411       *c2 = latin_a_char_to_byte2[c - 0x100];
412     }
413   else if (c < MIN_CHAR_GREEK)
414     {
415       *charset = Vcharset_ucs_bmp;
416       *c1 = c >> 8;
417       *c2 = c & 0xff;
418     }
419   else if (c <= MAX_CHAR_GREEK)
420     {
421       *charset = Vcharset_greek_iso8859_7;
422       *c1 = c - MIN_CHAR_GREEK + 0x20;
423       *c2 = 0;
424     }
425   else if (c < MIN_CHAR_CYRILLIC)
426     {
427       *charset = Vcharset_ucs_bmp;
428       *c1 = c >> 8;
429       *c2 = c & 0xff;
430     }
431   else if (c <= MAX_CHAR_CYRILLIC)
432     {
433       *charset = Vcharset_cyrillic_iso8859_5;
434       *c1 = c - MIN_CHAR_CYRILLIC + 0x20;
435       *c2 = 0;
436     }
437   else if (c < MIN_CHAR_HEBREW)
438     {
439       *charset = Vcharset_ucs_bmp;
440       *c1 = c >> 8;
441       *c2 = c & 0xff;
442     }
443   else if (c <= MAX_CHAR_HEBREW)
444     {
445       *charset = Vcharset_hebrew_iso8859_8;
446       *c1 = c - MIN_CHAR_HEBREW + 0x20;
447       *c2 = 0;
448     }
449   else if (c < MIN_CHAR_THAI)
450     {
451       *charset = Vcharset_ucs_bmp;
452       *c1 = c >> 8;
453       *c2 = c & 0xff;
454     }
455   else if (c <= MAX_CHAR_THAI)
456     {
457       *charset = Vcharset_thai_tis620;
458       *c1 = c - MIN_CHAR_THAI + 0x20;
459       *c2 = 0;
460     }
461   else if (c < MIN_CHAR_HALFWIDTH_KATAKANA)
462     {
463       *charset = Vcharset_ucs_bmp;
464       *c1 = c >> 8;
465       *c2 = c & 0xff;
466     }
467   else if (c <= MAX_CHAR_HALFWIDTH_KATAKANA)
468     {
469       *charset = Vcharset_katakana_jisx0201;
470       *c1 = c - MIN_CHAR_HALFWIDTH_KATAKANA + 0x20;
471       *c2 = 0;
472     }
473   else if (c <= MAX_CHAR_94)
474     {
475       *charset
476         = CHARSET_BY_ATTRIBUTES (CHARSET_TYPE_94,
477                                  ((c - MIN_CHAR_94) / 94) + '0',
478                                  CHARSET_LEFT_TO_RIGHT);
479       *c1 = ((c - MIN_CHAR_94) % 94) + 33;
480       *c2 = 0;
481     }
482   else if (c <= MAX_CHAR_96)
483     {
484       *charset
485         = CHARSET_BY_ATTRIBUTES (CHARSET_TYPE_96,
486                                  ((c - MIN_CHAR_96) / 96) + '0',
487                                  CHARSET_LEFT_TO_RIGHT);
488       *c1 = ((c - MIN_CHAR_96) % 96) + 32;
489       *c2 = 0;
490     }
491   else if (c <= MAX_CHAR_94x94)
492     {
493       *charset
494         = CHARSET_BY_ATTRIBUTES (CHARSET_TYPE_94X94,
495                                  ((c - MIN_CHAR_94x94) / (94 * 94)) + '0',
496                                  CHARSET_LEFT_TO_RIGHT);
497       *c1 = (((c - MIN_CHAR_94x94) / 94) % 94) + 33;
498       *c2 = ((c - MIN_CHAR_94x94) % 94) + 33;
499     }
500   else if (c <= MAX_CHAR_96x96)
501     {
502       *charset
503         = CHARSET_BY_ATTRIBUTES (CHARSET_TYPE_96X96,
504                                  ((c - MIN_CHAR_96x96) / (96 * 96)) + '0',
505                                  CHARSET_LEFT_TO_RIGHT);
506       *c1 = (((c - MIN_CHAR_96x96) / 96) % 96) + 32;
507       *c2 = ((c - MIN_CHAR_96x96) % 96) + 32;
508     }
509   else
510     {
511       printf("u+%x", c);
512       abort();
513     }
514 }
515
516 #define BREAKUP_CHAR(ch, charset, b1, b2) \
517   breakup_char_1 (ch, &(charset), &(b1), &(b2))
518
519 INLINE Lisp_Object CHAR_CHARSET (Emchar ch);
520 INLINE Lisp_Object
521 CHAR_CHARSET (Emchar ch)
522 {
523   Lisp_Object charset;
524   int b1, b2;
525
526   BREAKUP_CHAR(ch, charset, b1, b2);
527   return charset;
528 }
529
530 #define CHAR_LEADING_BYTE(c) (XCHARSET_LEADING_BYTE(CHAR_CHARSET(c)))
531
532 \f
533 #ifdef ENABLE_COMPOSITE_CHARS
534 /************************************************************************/
535 /*                           Composite characters                       */
536 /************************************************************************/
537
538 Emchar lookup_composite_char (Bufbyte *str, int len);
539 Lisp_Object composite_char_string (Emchar ch);
540 #endif /* ENABLE_COMPOSITE_CHARS */
541
542 \f
543 /************************************************************************/
544 /*                            Exported functions                        */
545 /************************************************************************/
546
547 EXFUN (Ffind_charset, 1);
548 EXFUN (Fget_charset, 1);
549
550 extern Lisp_Object Vcharset_chinese_big5_1;
551 extern Lisp_Object Vcharset_chinese_big5_2;
552 extern Lisp_Object Vcharset_japanese_jisx0208;
553 extern Lisp_Object Vcharset_japanese_jisx0212;
554
555 #endif /* _XEMACS_CHAR_UCS_H */