1 /* Header for UCS-4 character representation.
2 Copyright (C) 1999,2000,2001,2002,2003 MORIOKA Tomohiko
4 This file is part of XEmacs.
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 #ifndef INCLUDED_char_ucs_h_
22 #define INCLUDED_char_ucs_h_
27 EXFUN (Fmake_directory_internal, 1);
29 extern Lisp_Object Vchar_attribute_hash_table;
31 #define valid_char_p(ch) 1
33 #define CHAR_ASCII_P(ch) ((ch) <= 0x7F)
36 /************************************************************************/
37 /* Exported functions */
38 /************************************************************************/
40 extern Lisp_Object Vcharset_ucs;
41 extern Lisp_Object Vcharset_latin_jisx0201;
42 extern Lisp_Object Vcharset_chinese_big5;
43 extern Lisp_Object Vcharset_chinese_big5_1;
44 extern Lisp_Object Vcharset_chinese_big5_2;
45 extern Lisp_Object Vcharset_japanese_jisx0208;
46 extern Lisp_Object Vcharset_japanese_jisx0208_1990;
47 extern Lisp_Object Vcharset_japanese_jisx0212;
49 EXFUN (Fget_charset, 1);
51 extern Lisp_Object Qucs;
53 Lisp_Object put_char_ccs_code_point (Lisp_Object character,
54 Lisp_Object ccs, Lisp_Object value);
55 Lisp_Object remove_char_ccs (Lisp_Object character, Lisp_Object ccs);
58 /************************************************************************/
59 /* Definition of leading bytes */
60 /************************************************************************/
62 typedef short Charset_ID;
64 #define MIN_LEADING_BYTE -0x200
67 #define LEADING_BYTE_UCS (MIN_LEADING_BYTE + 1)
69 /* represent normal 80-9F */
70 #define LEADING_BYTE_CONTROL_1 (MIN_LEADING_BYTE + 2)
72 /* ISO/IEC 10646 BMP */
73 #define LEADING_BYTE_UCS_BMP (MIN_LEADING_BYTE + 3)
75 /* ISO/IEC 10646 SMP */
76 #define LEADING_BYTE_UCS_SMP (MIN_LEADING_BYTE + 4)
78 /* ISO/IEC 10646 SIP */
79 #define LEADING_BYTE_UCS_SIP (MIN_LEADING_BYTE + 5)
81 /* ISO/IEC 10646 for GB */
82 #define LEADING_BYTE_UCS_GB (MIN_LEADING_BYTE + 6)
84 /* Japanese JIS X0208 Common 2/4 2/{(8),9,10,11} 4/2 (B) */
85 #define LEADING_BYTE_JIS_X0208 (MIN_LEADING_BYTE + 11)
87 /* Japanese JIS X0208-1990 2/4 2/{(8),9,10,11} 4/2 (B) */
88 #define LEADING_BYTE_JAPANESE_JISX0208_1990 (MIN_LEADING_BYTE + 12)
90 /* Chinese GB 12345-1990 */
91 #define LEADING_BYTE_CHINESE_GB12345 (MIN_LEADING_BYTE + 13)
93 #define LEADING_BYTE_CHINESE_BIG5 (MIN_LEADING_BYTE + 20)
95 /* Big5 Level 1 2/4 2/{(8),9,10,11} 4/0 '0' */
96 #define LEADING_BYTE_CHINESE_BIG5_1 (MIN_LEADING_BYTE + 21)
98 /* Big5 Level 2 2/4 2/{(8),9,10,11} 4/0 '1' */
99 #define LEADING_BYTE_CHINESE_BIG5_2 (MIN_LEADING_BYTE + 22)
102 #define LEADING_BYTE_LATIN_VISCII (MIN_LEADING_BYTE + 24)
104 /* MULE VISCII-LOWER (CHARSET_ID_OFFSET_96 + '1') */
105 #define LEADING_BYTE_LATIN_VISCII_LOWER (MIN_LEADING_BYTE + 25)
107 /* MULE VISCII-UPPER (CHARSET_ID_OFFSET_96 + '2') */
108 #define LEADING_BYTE_LATIN_VISCII_UPPER (MIN_LEADING_BYTE + 26)
110 #define LEADING_BYTE_ETHIOPIC_UCS (MIN_LEADING_BYTE + 27)
112 #define MIN_LEADING_BYTE_PRIVATE (MIN_LEADING_BYTE + 97)
113 #define MAX_LEADING_BYTE_PRIVATE -1
117 #define LEADING_BYTE_ASCII 6 /* (CHARSET_ID_OFFSET_94 + 'B') */
119 /* Right half of JIS X0201-1976 */
120 #define LEADING_BYTE_KATAKANA_JISX0201 13 /* (CHARSET_ID_OFFSET_94 + 'I') */
122 /* Left half of JIS X0201-1976 */
123 #define LEADING_BYTE_LATIN_JISX0201 14 /* (CHARSET_ID_OFFSET_94 + 'J') */
126 /* #define CHARSET_ID_OFFSET_96 (CHARSET_ID_OFFSET_94 + 80) */
128 /* Right half of ISO 8859-1 */
129 #define LEADING_BYTE_LATIN_ISO8859_1 100 /* (CHARSET_ID_OFFSET_96 + 'A') */
131 /* Right half of ISO 8859-2 */
132 #define LEADING_BYTE_LATIN_ISO8859_2 101 /* (CHARSET_ID_OFFSET_96 + 'B') */
134 /* Right half of ISO 8859-3 */
135 #define LEADING_BYTE_LATIN_ISO8859_3 109 /* (CHARSET_ID_OFFSET_96 + 'C') */
137 /* Right half of ISO 8859-4 */
138 #define LEADING_BYTE_LATIN_ISO8859_4 110 /* (CHARSET_ID_OFFSET_96 + 'D') */
140 /* Right half of ISO 8859-7 */
141 #define LEADING_BYTE_GREEK_ISO8859_7 126 /* (CHARSET_ID_OFFSET_96 + 'F') */
143 /* Right half of ISO 8859-6 */
144 #define LEADING_BYTE_ARABIC_ISO8859_6 127 /* (CHARSET_ID_OFFSET_96 + 'G') */
146 /* Right half of ISO 8859-8 */
147 #define LEADING_BYTE_HEBREW_ISO8859_8 138 /* (CHARSET_ID_OFFSET_96 + 'H') */
149 /* Right half of ISO 8859-5 */
150 #define LEADING_BYTE_CYRILLIC_ISO8859_5 144 /* (CHARSET_ID_OFFSET_96 + 'L') */
152 /* Right half of ISO 8859-9 */
153 #define LEADING_BYTE_LATIN_ISO8859_9 148 /* (CHARSET_ID_OFFSET_96 + 'M') */
156 #define LEADING_BYTE_THAI_TIS620 166 /* (CHARSET_ID_OFFSET_96 + 'T') */
158 /* Right-hand Part of the VSCII-2 (TCVN 5712:1983) */
159 #define LEADING_BYTE_LATIN_TCVN5712 180 /* F = 5/10 0x5A `Z' */
162 /* #define CHARSET_ID_OFFSET_94x94 (CHARSET_ID_OFFSET_96 + 80) */
164 /* #define MIN_LEADING_BYTE_PRIVATE_2 ('0' + CHARSET_ID_OFFSET_94x94) */
165 /* #define MAX_LEADING_BYTE_PRIVATE_2 ('?' + CHARSET_ID_OFFSET_94x94) */
167 /* Japanese JIS X0208-1978 2/4 2/{(8),9,10,11} 4/0 (@) */
168 #define LEADING_BYTE_JAPANESE_JISX0208_1978 42
170 /* Chinese Hanzi GB2312-1980 2/4 2/{(8),9,10,11} 4/1 (A) */
171 #define LEADING_BYTE_CHINESE_GB2312 58
173 /* Japanese JIS X0208-1983 2/4 2/{(8),9,10,11} 4/2 (B) */
174 #define LEADING_BYTE_JAPANESE_JISX0208 87
176 /* Hangul KS C5601-1987 2/4 2/{8,9,10,11} 4/3 (C) */
177 #define LEADING_BYTE_KOREAN_KSC5601 149
179 /* Japanese JIS X0212-1990 2/4 2/{8,9,10,11} 4/4 (D) */
180 #define LEADING_BYTE_JAPANESE_JISX0212 159
182 /* CCITT Extended GB 2/4 2/{8,9,10,11} 4/5 (E) */
183 #define LEADING_BYTE_CHINESE_CCITT_GB 165
185 /* Chinese CNS11643 Set 1 2/4 2/{8,9,10,11} 4/7 (G) */
186 #define LEADING_BYTE_CHINESE_CNS11643_1 171
188 /* Chinese CNS11643 Set 2 2/4 2/{8,9,10,11} 4/8 (H) */
189 #define LEADING_BYTE_CHINESE_CNS11643_2 172
191 /* Chinese CNS11643 Set 3 2/4 2/{8,9,10,11} 4/9 (I) */
192 #define LEADING_BYTE_CHINESE_CNS11643_3 183
194 /* Chinese CNS11643 Set 4 2/4 2/{8,9,10,11} 4/10 (J) */
195 #define LEADING_BYTE_CHINESE_CNS11643_4 184
197 /* Chinese CNS11643 Set 5 2/4 2/{8,9,10,11} 4/11 (K) */
198 #define LEADING_BYTE_CHINESE_CNS11643_5 185
200 /* Chinese CNS11643 Set 6 2/4 2/{8,9,10,11} 4/12 (L) */
201 #define LEADING_BYTE_CHINESE_CNS11643_6 186
203 /* Chinese CNS11643 Set 7 2/4 2/{8,9,10,11} 4/13 (M) */
204 #define LEADING_BYTE_CHINESE_CNS11643_7 187
206 /* DPRK Hangul KPS 9566-1997 2/4 2/{8,9,10,11} 4/14 (N) */
207 #define LEADING_BYTE_KOREAN_KPS9566 202
210 #define NUM_LEADING_BYTES (80 * 3 - MIN_LEADING_BYTE)
213 /************************************************************************/
214 /* Information about a particular character set */
215 /************************************************************************/
219 struct lcrecord_header header;
223 Lisp_Object doc_string;
224 Lisp_Object registry;
225 Lisp_Object short_name;
226 Lisp_Object long_name;
228 Lisp_Object reverse_direction_charset;
230 Lisp_Object ccl_program;
232 /* Final byte of this character set in ISO2022 designating escape sequence */
235 /* Number of columns a character in this charset takes up, on TTY
236 devices. Not used for X devices. */
237 unsigned int columns;
239 /* Direction of this character set */
240 unsigned int direction;
242 /* Number of bytes used in encoding of this character set (1 .. 4) */
243 unsigned short dimension;
245 /* Number of chars in each dimension (94, 96, 128, 256) */
246 unsigned short chars;
248 /* Which half of font to be used to display this character set */
249 unsigned int graphic;
251 /* Code-point->character mapping table */
252 Lisp_Object decoding_table;
257 /* Range of character code */
258 int min_code, max_code;
260 /* Offset for external code */
263 /* Type of conversion from mother CCS */
264 unsigned char conversion;
266 /* Offset for each byte */
269 typedef struct Lisp_Charset Lisp_Charset;
271 DECLARE_LRECORD (charset, Lisp_Charset);
272 #define XCHARSET(x) XRECORD (x, charset, Lisp_Charset)
273 #define XSETCHARSET(x, p) XSETRECORD (x, p, charset)
274 #define CHARSETP(x) RECORDP (x, charset)
275 #define CHECK_CHARSET(x) CHECK_RECORD (x, charset)
276 #define CONCHECK_CHARSET(x) CONCHECK_RECORD (x, charset)
278 #define CHARSET_LEFT_TO_RIGHT 0
279 #define CHARSET_RIGHT_TO_LEFT 1
281 /* Leading byte and id have been regrouped. -- OG */
282 #define CHARSET_ID(cs) ((cs)->id)
283 #define CHARSET_LEADING_BYTE(cs) (CHARSET_ID(cs))
284 #define CHARSET_NAME(cs) ((cs)->name)
285 #define CHARSET_SHORT_NAME(cs) ((cs)->short_name)
286 #define CHARSET_LONG_NAME(cs) ((cs)->long_name)
287 #define CHARSET_COLUMNS(cs) ((cs)->columns)
288 #define CHARSET_GRAPHIC(cs) ((cs)->graphic)
289 #define CHARSET_DIRECTION(cs) ((cs)->direction)
290 #define CHARSET_FINAL(cs) ((cs)->final)
291 #define CHARSET_DOC_STRING(cs) ((cs)->doc_string)
292 #define CHARSET_REGISTRY(cs) ((cs)->registry)
293 #define CHARSET_CCL_PROGRAM(cs) ((cs)->ccl_program)
294 #define CHARSET_DIMENSION(cs) ((cs)->dimension)
295 #define CHARSET_CHARS(cs) ((cs)->chars)
296 #define CHARSET_REVERSE_DIRECTION_CHARSET(cs) ((cs)->reverse_direction_charset)
297 #define CHARSET_DECODING_TABLE(cs) ((cs)->decoding_table)
298 #define CHARSET_MIN_CODE(cs) ((cs)->min_code)
299 #define CHARSET_MAX_CODE(cs) ((cs)->max_code)
300 #define CHARSET_CODE_OFFSET(cs) ((cs)->code_offset)
301 #define CHARSET_BYTE_OFFSET(cs) ((cs)->byte_offset)
302 #define CHARSET_MOTHER(cs) ((cs)->mother)
303 #define CHARSET_CONVERSION(cs) ((cs)->conversion)
305 INLINE_HEADER int CHARSET_BYTE_SIZE (Lisp_Charset* cs);
307 CHARSET_BYTE_SIZE (Lisp_Charset* cs)
309 /* ad-hoc method for `ascii' */
310 if ((CHARSET_CHARS (cs) == 94) &&
311 (CHARSET_BYTE_OFFSET (cs) != 33))
312 return 128 - CHARSET_BYTE_OFFSET (cs);
314 return CHARSET_CHARS (cs);
317 INLINE_HEADER Lisp_Object CHARSET_ENCODING_TABLE (Lisp_Charset* cs);
318 INLINE_HEADER Lisp_Object
319 CHARSET_ENCODING_TABLE (Lisp_Charset* cs)
321 return Fgethash (CHARSET_NAME(cs),
322 Vchar_attribute_hash_table,
326 #define CONVERSION_IDENTICAL 0
327 #define CONVERSION_94 1
328 #define CONVERSION_96 2
329 #define CONVERSION_94x94 3
330 #define CONVERSION_96x96 4
331 #define CONVERSION_94x94x94 5
332 #define CONVERSION_96x96x96 6
333 #define CONVERSION_94x94x94x94 7
334 #define CONVERSION_96x96x96x96 8
335 #define CONVERSION_94x60 9
336 #define CONVERSION_94x94x60 10
337 #define CONVERSION_94x94x94x60 11
338 #define CONVERSION_BIG5_1 12
339 #define CONVERSION_BIG5_2 13
341 #define XCHARSET_ID(cs) CHARSET_ID (XCHARSET (cs))
342 #define XCHARSET_NAME(cs) CHARSET_NAME (XCHARSET (cs))
343 #define XCHARSET_SHORT_NAME(cs) CHARSET_SHORT_NAME (XCHARSET (cs))
344 #define XCHARSET_LONG_NAME(cs) CHARSET_LONG_NAME (XCHARSET (cs))
345 #define XCHARSET_GRAPHIC(cs) CHARSET_GRAPHIC (XCHARSET (cs))
346 #define XCHARSET_DIRECTION(cs) CHARSET_DIRECTION (XCHARSET (cs))
347 #define XCHARSET_FINAL(cs) CHARSET_FINAL (XCHARSET (cs))
348 #define XCHARSET_DOC_STRING(cs) CHARSET_DOC_STRING (XCHARSET (cs))
349 #define XCHARSET_REGISTRY(cs) CHARSET_REGISTRY (XCHARSET (cs))
350 #define XCHARSET_LEADING_BYTE(cs) CHARSET_LEADING_BYTE (XCHARSET (cs))
351 #define XCHARSET_CCL_PROGRAM(cs) CHARSET_CCL_PROGRAM (XCHARSET (cs))
352 #define XCHARSET_DIMENSION(cs) CHARSET_DIMENSION (XCHARSET (cs))
353 #define XCHARSET_CHARS(cs) CHARSET_CHARS (XCHARSET (cs))
354 #define XCHARSET_BYTE_SIZE(cs) CHARSET_BYTE_SIZE (XCHARSET (cs))
355 #define XCHARSET_REVERSE_DIRECTION_CHARSET(cs) \
356 CHARSET_REVERSE_DIRECTION_CHARSET (XCHARSET (cs))
357 #define XCHARSET_DECODING_TABLE(cs) CHARSET_DECODING_TABLE(XCHARSET(cs))
358 #define XCHARSET_ENCODING_TABLE(cs) CHARSET_ENCODING_TABLE(XCHARSET(cs))
359 #define XCHARSET_MIN_CODE(cs) CHARSET_MIN_CODE(XCHARSET(cs))
360 #define XCHARSET_MAX_CODE(cs) CHARSET_MAX_CODE(XCHARSET(cs))
361 #define XCHARSET_CODE_OFFSET(cs) CHARSET_CODE_OFFSET(XCHARSET(cs))
362 #define XCHARSET_BYTE_OFFSET(cs) CHARSET_BYTE_OFFSET(XCHARSET(cs))
363 #define XCHARSET_MOTHER(cs) CHARSET_MOTHER(XCHARSET(cs))
364 #define XCHARSET_CONVERSION(cs) CHARSET_CONVERSION(XCHARSET(cs))
366 struct charset_lookup {
367 /* Table of charsets indexed by (leading byte - 128). */
368 Lisp_Object charset_by_leading_byte[NUM_LEADING_BYTES];
370 /* Table of charsets indexed by type/final-byte/direction. */
371 Lisp_Object charset_by_attributes[4][128];
373 Charset_ID next_allocated_leading_byte;
376 extern struct charset_lookup *chlook;
378 #ifdef ERROR_CHECK_TYPECHECK
379 /* int not Bufbyte even though that is the actual type of a leading byte.
380 This way, out-ot-range values will get caught rather than automatically
382 INLINE_HEADER Lisp_Object CHARSET_BY_LEADING_BYTE (Charset_ID lb);
383 INLINE_HEADER Lisp_Object
384 CHARSET_BY_LEADING_BYTE (Charset_ID lb)
386 assert (lb >= MIN_LEADING_BYTE &&
387 lb < (MIN_LEADING_BYTE + NUM_LEADING_BYTES));
388 return chlook->charset_by_leading_byte[lb - MIN_LEADING_BYTE];
393 #define CHARSET_BY_LEADING_BYTE(lb) \
394 (chlook->charset_by_leading_byte[(lb) - MIN_LEADING_BYTE])
398 INLINE_HEADER Lisp_Object
399 CHARSET_BY_ATTRIBUTES (int chars, int dimension, int final, int dir);
400 INLINE_HEADER Lisp_Object
401 CHARSET_BY_ATTRIBUTES (int chars, int dimension, int final, int dir)
407 else if (chars == 96)
411 type += dimension == 1 ? 0 : 2;
412 return chlook->charset_by_attributes[type][final];
416 /************************************************************************/
417 /* Dealing with characters */
418 /************************************************************************/
420 #define MAX_CHAR_BASIC_LATIN 0x007F
423 #define MIN_CHAR_HEBREW 0x0590
424 #define MAX_CHAR_HEBREW 0x05EF
427 #define MIN_CHAR_THAI 0x0E00
428 #define MAX_CHAR_THAI 0x0E5F
431 #define MIN_CHAR_HIRAGANA 0x3041
432 #define MAX_CHAR_HIRAGANA 0x3093
434 #define MIN_CHAR_KATAKANA 0x30A1
435 #define MAX_CHAR_KATAKANA 0x30F6
438 #define MIN_CHAR_HALFWIDTH_KATAKANA 0xFF61
439 #define MAX_CHAR_HALFWIDTH_KATAKANA 0xFF9F
441 #define MAX_CHAR_BMP 0x00FFFF
443 #define MIN_CHAR_SMP 0x010000
444 #define MAX_CHAR_SMP 0x01FFFF
446 #define MIN_CHAR_SIP 0x020000
447 #define MAX_CHAR_SIP 0x02FFFF
450 #define MIN_CHAR_DAIKANWA 0x00E00000
451 #define MAX_CHAR_DAIKANWA (MIN_CHAR_DAIKANWA + 50100) /* 0xE0FFFF */
453 #define MIN_CHAR_CBETA 0x00E20000
454 #define MAX_CHAR_CBETA 0x00E2FFFF
456 #define MIN_CHAR_CHINA3_JEF 0x00E80000
457 #define MAX_CHAR_CHINA3_JEF 0x00E8FFFF
460 #define MIN_CHAR_94 0x00E90940
461 #define MAX_CHAR_94 (MIN_CHAR_94 + 94 * 80 - 1)
462 #define MIN_CHAR_96 (MIN_CHAR_94 + 94 * 80)
463 #define MAX_CHAR_96 (MIN_CHAR_96 + 96 * 80 - 1)
465 #define MIN_CHAR_94x94 0xE9F6C0
466 #define MIN_CHAR_JIS_X0208_1990 (MIN_CHAR_94x94 + 94 * 94 * 79)
467 #define MAX_CHAR_94x94 (MIN_CHAR_94x94 + 94 * 94 * 80 - 1)
468 #define MAX_CHAR_JIS_X0208_1990 MAX_CHAR_94x94
469 #define MIN_CHAR_96x96 0xF4C000
470 #define MAX_CHAR_96x96 (MIN_CHAR_96x96 + 96 * 96 * 80 - 1)
473 #define MIN_CHAR_GT 0x61000000
474 #define MAX_CHAR_GT (MIN_CHAR_GT + 67547)
476 #define MIN_CHAR_BIG5_CDP 0x62000000
477 #define MAX_CHAR_BIG5_CDP 0x6200FFFF
479 #define MIN_CHAR_HANZIKU_1 (0x62000000 + 65536 * 1)
480 #define MAX_CHAR_HANZIKU_1 (0x62000000 + 65536 * 1 + 65535)
481 #define MIN_CHAR_HANZIKU_2 (0x62000000 + 65536 * 2)
482 #define MAX_CHAR_HANZIKU_2 (0x62000000 + 65536 * 2 + 65535)
483 #define MIN_CHAR_HANZIKU_3 (0x62000000 + 65536 * 3)
484 #define MAX_CHAR_HANZIKU_3 (0x62000000 + 65536 * 3 + 65535)
485 #define MIN_CHAR_HANZIKU_4 (0x62000000 + 65536 * 4)
486 #define MAX_CHAR_HANZIKU_4 (0x62000000 + 65536 * 4 + 65535)
487 #define MIN_CHAR_HANZIKU_5 (0x62000000 + 65536 * 5)
488 #define MAX_CHAR_HANZIKU_5 (0x62000000 + 65536 * 5 + 65535)
489 #define MIN_CHAR_HANZIKU_6 (0x62000000 + 65536 * 6)
490 #define MAX_CHAR_HANZIKU_6 (0x62000000 + 65536 * 6 + 65535)
491 #define MIN_CHAR_HANZIKU_7 (0x62000000 + 65536 * 7)
492 #define MAX_CHAR_HANZIKU_7 (0x62000000 + 65536 * 7 + 65535)
493 #define MIN_CHAR_HANZIKU_8 (0x62000000 + 65536 * 8)
494 #define MAX_CHAR_HANZIKU_8 (0x62000000 + 65536 * 8 + 65535)
495 #define MIN_CHAR_HANZIKU_9 (0x62000000 + 65536 * 9)
496 #define MAX_CHAR_HANZIKU_9 (0x62000000 + 65536 * 9 + 65535)
497 #define MIN_CHAR_HANZIKU_10 (0x62000000 + 65536 * 10)
498 #define MAX_CHAR_HANZIKU_10 (0x62000000 + 65536 * 10 + 65535)
499 #define MIN_CHAR_HANZIKU_11 (0x62000000 + 65536 * 11)
500 #define MAX_CHAR_HANZIKU_11 (0x62000000 + 65536 * 11 + 65535)
501 #define MIN_CHAR_HANZIKU_12 (0x62000000 + 65536 * 12)
502 #define MAX_CHAR_HANZIKU_12 (0x62000000 + 65536 * 12 + 65535)
505 Emchar decode_builtin_char (Lisp_Object charset, int code_point);
507 INLINE_HEADER Lisp_Object
508 get_ccs_octet_table (Lisp_Object table, Lisp_Object ccs, int code);
509 INLINE_HEADER Lisp_Object
510 get_ccs_octet_table (Lisp_Object table, Lisp_Object ccs, int code)
512 int byte_offset = XCHARSET_BYTE_OFFSET (ccs);
516 int idx = code - byte_offset;
518 if (idx < XVECTOR_LENGTH(table))
519 return XVECTOR_DATA(table)[idx];
527 INLINE_HEADER Lisp_Object
528 put_ccs_octet_table (Lisp_Object table, Lisp_Object ccs, int code,
530 INLINE_HEADER Lisp_Object
531 put_ccs_octet_table (Lisp_Object table, Lisp_Object ccs, int code,
534 int byte_offset = XCHARSET_BYTE_OFFSET (ccs);
535 int ccs_len = XCHARSET_BYTE_SIZE (ccs);
539 XVECTOR_DATA(table)[code - byte_offset] = value;
542 else if (EQ (table, value))
546 table = make_vector (ccs_len, table);
547 XVECTOR_DATA(table)[code - byte_offset] = value;
553 decoding_table_put_char (Lisp_Object ccs,
554 int code_point, Lisp_Object character);
556 decoding_table_put_char (Lisp_Object ccs,
557 int code_point, Lisp_Object character)
560 Lisp_Object table1 = XCHARSET_DECODING_TABLE (ccs);
561 int dim = XCHARSET_DIMENSION (ccs);
564 XCHARSET_DECODING_TABLE (ccs)
565 = put_ccs_octet_table (table1, ccs, code_point, character);
569 = get_ccs_octet_table (table1, ccs, (unsigned char)(code_point >> 8));
571 table2 = put_ccs_octet_table (table2, ccs,
572 (unsigned char)code_point, character);
573 XCHARSET_DECODING_TABLE (ccs)
574 = put_ccs_octet_table (table1, ccs,
575 (unsigned char)(code_point >> 8), table2);
580 = get_ccs_octet_table (table1, ccs, (unsigned char)(code_point >> 16));
582 = get_ccs_octet_table (table2, ccs, (unsigned char)(code_point >> 8));
584 table3 = put_ccs_octet_table (table3, ccs,
585 (unsigned char)code_point, character);
586 table2 = put_ccs_octet_table (table2, ccs,
587 (unsigned char)(code_point >> 8), table3);
588 XCHARSET_DECODING_TABLE (ccs)
589 = put_ccs_octet_table (table1, ccs,
590 (unsigned char)(code_point >> 16), table2);
592 else /* if (dim == 4) */
595 = get_ccs_octet_table (table1, ccs, (unsigned char)(code_point >> 24));
597 = get_ccs_octet_table (table2, ccs, (unsigned char)(code_point >> 16));
599 = get_ccs_octet_table (table3, ccs, (unsigned char)(code_point >> 8));
601 table4 = put_ccs_octet_table (table4, ccs,
602 (unsigned char)code_point, character);
603 table3 = put_ccs_octet_table (table3, ccs,
604 (unsigned char)(code_point >> 8), table4);
605 table2 = put_ccs_octet_table (table2, ccs,
606 (unsigned char)(code_point >> 16), table3);
607 XCHARSET_DECODING_TABLE (ccs)
608 = put_ccs_octet_table (table1, ccs,
609 (unsigned char)(code_point >> 24), table2);
612 Lisp_Object v = XCHARSET_DECODING_TABLE (ccs);
613 int dim = XCHARSET_DIMENSION (ccs);
614 int byte_offset = XCHARSET_BYTE_OFFSET (ccs);
617 int ccs_len = XVECTOR_LENGTH (v);
622 i = ((code_point >> (8 * dim)) & 255) - byte_offset;
623 nv = XVECTOR_DATA(v)[i];
628 if (EQ (nv, character))
631 nv = (XVECTOR_DATA(v)[i] = make_vector (ccs_len, Qnil));
638 XVECTOR_DATA(v)[i] = character;
643 decoding_table_remove_char (Lisp_Object ccs, int code_point);
645 decoding_table_remove_char (Lisp_Object ccs, int code_point)
647 decoding_table_put_char (ccs, code_point, Qunbound);
650 #ifdef HAVE_CHISE_CLIENT
651 Emchar load_char_decoding_entry_maybe (Lisp_Object ccs, int code_point);
654 Emchar decode_defined_char (Lisp_Object charset, int code_point);
656 INLINE_HEADER Emchar DECODE_CHAR (Lisp_Object charset, int code_point);
658 DECODE_CHAR (Lisp_Object charset, int code_point)
660 Emchar char_id = decode_defined_char (charset, code_point);
665 return decode_builtin_char (charset, code_point);
668 /* Return a character whose charset is CHARSET and position-codes
669 are C1 and C2. TYPE9N character ignores C2. */
671 INLINE_HEADER Emchar MAKE_CHAR (Lisp_Object charset, int c1, int c2);
673 MAKE_CHAR (Lisp_Object charset, int c1, int c2)
675 if (XCHARSET_DIMENSION (charset) == 1)
676 return DECODE_CHAR (charset, c1);
678 return DECODE_CHAR (charset, (c1 << 8) | c2);
681 extern Lisp_Object Vcharacter_attribute_table;
683 int encode_builtin_char_1 (Emchar c, Lisp_Object* charset);
684 int charset_code_point (Lisp_Object charset, Emchar ch, int defined_only);
685 int range_charset_code_point (Lisp_Object charset, Emchar ch);
687 extern Lisp_Object Vdefault_coded_charset_priority_list;
688 EXFUN (Ffind_charset, 1);
690 INLINE_HEADER int encode_char_1 (Emchar ch, Lisp_Object* charset);
692 encode_char_1 (Emchar ch, Lisp_Object* charset)
694 Lisp_Object charsets = Vdefault_coded_charset_priority_list;
696 while (!NILP (charsets))
698 *charset = Ffind_charset (Fcar (charsets));
699 if (!NILP (*charset))
701 int code_point = charset_code_point (*charset, ch, 0);
706 charsets = Fcdr (charsets);
709 /* otherwise --- maybe for bootstrap */
710 return encode_builtin_char_1 (ch, charset);
713 #define ENCODE_CHAR(ch, charset) encode_char_1 (ch, &(charset))
716 breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2);
718 breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2)
720 int code_point = encode_char_1 (c, charset);
724 int dim = XCHARSET_DIMENSION (*charset);
731 else /* if (dim == 2) */
733 *c1 = code_point >> 8;
734 *c2 = code_point & 255;
742 #define BREAKUP_CHAR(ch, charset, b1, b2) \
743 breakup_char_1 (ch, &(charset), &(b1), &(b2))
745 INLINE_HEADER Lisp_Object CHAR_CHARSET (Emchar ch);
746 INLINE_HEADER Lisp_Object
747 CHAR_CHARSET (Emchar ch)
751 ENCODE_CHAR (ch, charset);
755 #define CHAR_CHARSET_ID(c) (XCHARSET_ID(CHAR_CHARSET(c)))
756 #define CHAR_COLUMNS(c) (CHARSET_COLUMNS(XCHARSET(CHAR_CHARSET(c))))
765 INLINE_HEADER Charc CHAR_TO_CHARC (Emchar ch);
767 CHAR_TO_CHARC (Emchar ch)
771 cc.code_point = encode_char_1 (ch, &cc.charset);
775 #endif /* INCLUDED_char_ucs_h_ */