428
|
1 /* Functions to handle multilingual characters.
|
|
2 Copyright (C) 1992, 1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995 Sun Microsystems, Inc.
|
|
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 /* Synched up with: FSF 20.3. Not in FSF. */
|
|
23
|
|
24 /* Rewritten by Ben Wing <ben@xemacs.org>. */
|
|
25
|
|
26 #include <config.h>
|
|
27 #include "lisp.h"
|
|
28
|
|
29 #include "buffer.h"
|
|
30 #include "chartab.h"
|
|
31 #include "elhash.h"
|
|
32 #include "lstream.h"
|
|
33 #include "device.h"
|
|
34 #include "faces.h"
|
|
35 #include "mule-ccl.h"
|
|
36
|
|
37 /* The various pre-defined charsets. */
|
|
38
|
|
39 Lisp_Object Vcharset_ascii;
|
|
40 Lisp_Object Vcharset_control_1;
|
|
41 Lisp_Object Vcharset_latin_iso8859_1;
|
|
42 Lisp_Object Vcharset_latin_iso8859_2;
|
|
43 Lisp_Object Vcharset_latin_iso8859_3;
|
|
44 Lisp_Object Vcharset_latin_iso8859_4;
|
|
45 Lisp_Object Vcharset_thai_tis620;
|
|
46 Lisp_Object Vcharset_greek_iso8859_7;
|
|
47 Lisp_Object Vcharset_arabic_iso8859_6;
|
|
48 Lisp_Object Vcharset_hebrew_iso8859_8;
|
|
49 Lisp_Object Vcharset_katakana_jisx0201;
|
|
50 Lisp_Object Vcharset_latin_jisx0201;
|
|
51 Lisp_Object Vcharset_cyrillic_iso8859_5;
|
|
52 Lisp_Object Vcharset_latin_iso8859_9;
|
|
53 Lisp_Object Vcharset_japanese_jisx0208_1978;
|
|
54 Lisp_Object Vcharset_chinese_gb2312;
|
|
55 Lisp_Object Vcharset_japanese_jisx0208;
|
|
56 Lisp_Object Vcharset_korean_ksc5601;
|
|
57 Lisp_Object Vcharset_japanese_jisx0212;
|
|
58 Lisp_Object Vcharset_chinese_cns11643_1;
|
|
59 Lisp_Object Vcharset_chinese_cns11643_2;
|
|
60 Lisp_Object Vcharset_chinese_big5_1;
|
|
61 Lisp_Object Vcharset_chinese_big5_2;
|
|
62
|
|
63 #ifdef ENABLE_COMPOSITE_CHARS
|
|
64 Lisp_Object Vcharset_composite;
|
|
65
|
|
66 /* Hash tables for composite chars. One maps string representing
|
|
67 composed chars to their equivalent chars; one goes the
|
|
68 other way. */
|
|
69 Lisp_Object Vcomposite_char_char2string_hash_table;
|
|
70 Lisp_Object Vcomposite_char_string2char_hash_table;
|
|
71
|
|
72 static int composite_char_row_next;
|
|
73 static int composite_char_col_next;
|
|
74
|
|
75 #endif /* ENABLE_COMPOSITE_CHARS */
|
|
76
|
|
77 struct charset_lookup *chlook;
|
|
78
|
|
79 static const struct lrecord_description charset_lookup_description_1[] = {
|
440
|
80 { XD_LISP_OBJECT_ARRAY, offsetof (struct charset_lookup, charset_by_leading_byte), 128+4*128*2 },
|
428
|
81 { XD_END }
|
|
82 };
|
|
83
|
|
84 static const struct struct_description charset_lookup_description = {
|
440
|
85 sizeof (struct charset_lookup),
|
428
|
86 charset_lookup_description_1
|
|
87 };
|
|
88
|
|
89 /* Table of number of bytes in the string representation of a character
|
|
90 indexed by the first byte of that representation.
|
|
91
|
|
92 rep_bytes_by_first_byte(c) is more efficient than the equivalent
|
|
93 canonical computation:
|
|
94
|
438
|
95 XCHARSET_REP_BYTES (CHARSET_BY_LEADING_BYTE (c)) */
|
428
|
96
|
438
|
97 const Bytecount rep_bytes_by_first_byte[0xA0] =
|
428
|
98 { /* 0x00 - 0x7f are for straight ASCII */
|
|
99 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
100 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
101 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
102 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
103 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
104 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
105 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
106 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
107 /* 0x80 - 0x8f are for Dimension-1 official charsets */
|
|
108 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
109 /* 0x90 - 0x9d are for Dimension-2 official charsets */
|
|
110 /* 0x9e is for Dimension-1 private charsets */
|
|
111 /* 0x9f is for Dimension-2 private charsets */
|
|
112 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
|
|
113 };
|
|
114
|
|
115 Lisp_Object Qcharsetp;
|
|
116
|
|
117 /* Qdoc_string, Qdimension, Qchars defined in general.c */
|
|
118 Lisp_Object Qregistry, Qfinal, Qgraphic;
|
|
119 Lisp_Object Qdirection;
|
|
120 Lisp_Object Qreverse_direction_charset;
|
|
121 Lisp_Object Qleading_byte;
|
|
122 Lisp_Object Qshort_name, Qlong_name;
|
|
123
|
|
124 Lisp_Object Qascii,
|
|
125 Qcontrol_1,
|
|
126 Qlatin_iso8859_1,
|
|
127 Qlatin_iso8859_2,
|
|
128 Qlatin_iso8859_3,
|
|
129 Qlatin_iso8859_4,
|
|
130 Qthai_tis620,
|
|
131 Qgreek_iso8859_7,
|
|
132 Qarabic_iso8859_6,
|
|
133 Qhebrew_iso8859_8,
|
|
134 Qkatakana_jisx0201,
|
|
135 Qlatin_jisx0201,
|
|
136 Qcyrillic_iso8859_5,
|
|
137 Qlatin_iso8859_9,
|
|
138 Qjapanese_jisx0208_1978,
|
|
139 Qchinese_gb2312,
|
|
140 Qjapanese_jisx0208,
|
|
141 Qkorean_ksc5601,
|
|
142 Qjapanese_jisx0212,
|
|
143 Qchinese_cns11643_1,
|
|
144 Qchinese_cns11643_2,
|
|
145 Qchinese_big5_1,
|
|
146 Qchinese_big5_2,
|
|
147 Qcomposite;
|
|
148
|
|
149 Lisp_Object Ql2r, Qr2l;
|
|
150
|
|
151 Lisp_Object Vcharset_hash_table;
|
|
152
|
|
153 /* Composite characters are characters constructed by overstriking two
|
|
154 or more regular characters.
|
|
155
|
|
156 1) The old Mule implementation involves storing composite characters
|
|
157 in a buffer as a tag followed by all of the actual characters
|
|
158 used to make up the composite character. I think this is a bad
|
|
159 idea; it greatly complicates code that wants to handle strings
|
|
160 one character at a time because it has to deal with the possibility
|
|
161 of great big ungainly characters. It's much more reasonable to
|
|
162 simply store an index into a table of composite characters.
|
|
163
|
|
164 2) The current implementation only allows for 16,384 separate
|
|
165 composite characters over the lifetime of the XEmacs process.
|
|
166 This could become a potential problem if the user
|
|
167 edited lots of different files that use composite characters.
|
|
168 Due to FSF bogosity, increasing the number of allowable
|
|
169 composite characters under Mule would decrease the number
|
|
170 of possible faces that can exist. Mule already has shrunk
|
|
171 this to 2048, and further shrinkage would become uncomfortable.
|
|
172 No such problems exist in XEmacs.
|
|
173
|
|
174 Composite characters could be represented as 0x80 C1 C2 C3,
|
|
175 where each C[1-3] is in the range 0xA0 - 0xFF. This allows
|
|
176 for slightly under 2^20 (one million) composite characters
|
|
177 over the XEmacs process lifetime, and you only need to
|
|
178 increase the size of a Mule character from 19 to 21 bits.
|
|
179 Or you could use 0x80 C1 C2 C3 C4, allowing for about
|
|
180 85 million (slightly over 2^26) composite characters. */
|
|
181
|
|
182
|
|
183 /************************************************************************/
|
|
184 /* Basic Emchar functions */
|
|
185 /************************************************************************/
|
|
186
|
|
187 /* Convert a non-ASCII Mule character C into a one-character Mule-encoded
|
|
188 string in STR. Returns the number of bytes stored.
|
|
189 Do not call this directly. Use the macro set_charptr_emchar() instead.
|
|
190 */
|
|
191
|
|
192 Bytecount
|
|
193 non_ascii_set_charptr_emchar (Bufbyte *str, Emchar c)
|
|
194 {
|
|
195 Bufbyte *p;
|
|
196 Bufbyte lb;
|
|
197 int c1, c2;
|
|
198 Lisp_Object charset;
|
|
199
|
|
200 p = str;
|
|
201 BREAKUP_CHAR (c, charset, c1, c2);
|
|
202 lb = CHAR_LEADING_BYTE (c);
|
|
203 if (LEADING_BYTE_PRIVATE_P (lb))
|
|
204 *p++ = PRIVATE_LEADING_BYTE_PREFIX (lb);
|
|
205 *p++ = lb;
|
|
206 if (EQ (charset, Vcharset_control_1))
|
|
207 c1 += 0x20;
|
|
208 *p++ = c1 | 0x80;
|
|
209 if (c2)
|
|
210 *p++ = c2 | 0x80;
|
|
211
|
|
212 return (p - str);
|
|
213 }
|
|
214
|
|
215 /* Return the first character from a Mule-encoded string in STR,
|
|
216 assuming it's non-ASCII. Do not call this directly.
|
|
217 Use the macro charptr_emchar() instead. */
|
|
218
|
|
219 Emchar
|
442
|
220 non_ascii_charptr_emchar (const Bufbyte *str)
|
428
|
221 {
|
|
222 Bufbyte i0 = *str, i1, i2 = 0;
|
|
223 Lisp_Object charset;
|
|
224
|
|
225 if (i0 == LEADING_BYTE_CONTROL_1)
|
|
226 return (Emchar) (*++str - 0x20);
|
|
227
|
|
228 if (LEADING_BYTE_PREFIX_P (i0))
|
|
229 i0 = *++str;
|
|
230
|
|
231 i1 = *++str & 0x7F;
|
|
232
|
|
233 charset = CHARSET_BY_LEADING_BYTE (i0);
|
|
234 if (XCHARSET_DIMENSION (charset) == 2)
|
|
235 i2 = *++str & 0x7F;
|
|
236
|
|
237 return MAKE_CHAR (charset, i1, i2);
|
|
238 }
|
|
239
|
|
240 /* Return whether CH is a valid Emchar, assuming it's non-ASCII.
|
|
241 Do not call this directly. Use the macro valid_char_p() instead. */
|
|
242
|
|
243 int
|
|
244 non_ascii_valid_char_p (Emchar ch)
|
|
245 {
|
|
246 int f1, f2, f3;
|
|
247
|
|
248 /* Must have only lowest 19 bits set */
|
|
249 if (ch & ~0x7FFFF)
|
|
250 return 0;
|
|
251
|
|
252 f1 = CHAR_FIELD1 (ch);
|
|
253 f2 = CHAR_FIELD2 (ch);
|
|
254 f3 = CHAR_FIELD3 (ch);
|
|
255
|
|
256 if (f1 == 0)
|
|
257 {
|
|
258 Lisp_Object charset;
|
|
259
|
|
260 if (f2 < MIN_CHAR_FIELD2_OFFICIAL ||
|
|
261 (f2 > MAX_CHAR_FIELD2_OFFICIAL && f2 < MIN_CHAR_FIELD2_PRIVATE) ||
|
|
262 f2 > MAX_CHAR_FIELD2_PRIVATE)
|
|
263 return 0;
|
|
264 if (f3 < 0x20)
|
|
265 return 0;
|
|
266
|
|
267 if (f3 != 0x20 && f3 != 0x7F && !(f2 >= MIN_CHAR_FIELD2_PRIVATE &&
|
|
268 f2 <= MAX_CHAR_FIELD2_PRIVATE))
|
|
269 return 1;
|
|
270
|
|
271 /*
|
|
272 NOTE: This takes advantage of the fact that
|
|
273 FIELD2_TO_OFFICIAL_LEADING_BYTE and
|
|
274 FIELD2_TO_PRIVATE_LEADING_BYTE are the same.
|
|
275 */
|
|
276 charset = CHARSET_BY_LEADING_BYTE (f2 + FIELD2_TO_OFFICIAL_LEADING_BYTE);
|
|
277 if (EQ (charset, Qnil))
|
|
278 return 0;
|
|
279 return (XCHARSET_CHARS (charset) == 96);
|
|
280 }
|
|
281 else
|
|
282 {
|
|
283 Lisp_Object charset;
|
|
284
|
|
285 if (f1 < MIN_CHAR_FIELD1_OFFICIAL ||
|
|
286 (f1 > MAX_CHAR_FIELD1_OFFICIAL && f1 < MIN_CHAR_FIELD1_PRIVATE) ||
|
|
287 f1 > MAX_CHAR_FIELD1_PRIVATE)
|
|
288 return 0;
|
|
289 if (f2 < 0x20 || f3 < 0x20)
|
|
290 return 0;
|
|
291
|
|
292 #ifdef ENABLE_COMPOSITE_CHARS
|
|
293 if (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE == LEADING_BYTE_COMPOSITE)
|
|
294 {
|
|
295 if (UNBOUNDP (Fgethash (make_int (ch),
|
|
296 Vcomposite_char_char2string_hash_table,
|
|
297 Qunbound)))
|
|
298 return 0;
|
|
299 return 1;
|
|
300 }
|
|
301 #endif /* ENABLE_COMPOSITE_CHARS */
|
|
302
|
|
303 if (f2 != 0x20 && f2 != 0x7F && f3 != 0x20 && f3 != 0x7F
|
|
304 && !(f1 >= MIN_CHAR_FIELD1_PRIVATE && f1 <= MAX_CHAR_FIELD1_PRIVATE))
|
|
305 return 1;
|
|
306
|
|
307 if (f1 <= MAX_CHAR_FIELD1_OFFICIAL)
|
|
308 charset =
|
|
309 CHARSET_BY_LEADING_BYTE (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE);
|
|
310 else
|
|
311 charset =
|
|
312 CHARSET_BY_LEADING_BYTE (f1 + FIELD1_TO_PRIVATE_LEADING_BYTE);
|
|
313
|
|
314 if (EQ (charset, Qnil))
|
|
315 return 0;
|
|
316 return (XCHARSET_CHARS (charset) == 96);
|
|
317 }
|
|
318 }
|
|
319
|
|
320
|
|
321 /************************************************************************/
|
|
322 /* Basic string functions */
|
|
323 /************************************************************************/
|
|
324
|
444
|
325 /* Copy the character pointed to by SRC into DST. Do not call this
|
|
326 directly. Use the macro charptr_copy_char() instead.
|
|
327 Return the number of bytes copied. */
|
428
|
328
|
|
329 Bytecount
|
444
|
330 non_ascii_charptr_copy_char (const Bufbyte *src, Bufbyte *dst)
|
428
|
331 {
|
444
|
332 unsigned int bytes = REP_BYTES_BY_FIRST_BYTE (*src);
|
|
333 unsigned int i;
|
|
334 for (i = bytes; i; i--, dst++, src++)
|
|
335 *dst = *src;
|
|
336 return bytes;
|
428
|
337 }
|
|
338
|
|
339
|
|
340 /************************************************************************/
|
|
341 /* streams of Emchars */
|
|
342 /************************************************************************/
|
|
343
|
|
344 /* Treat a stream as a stream of Emchar's rather than a stream of bytes.
|
|
345 The functions below are not meant to be called directly; use
|
|
346 the macros in insdel.h. */
|
|
347
|
|
348 Emchar
|
|
349 Lstream_get_emchar_1 (Lstream *stream, int ch)
|
|
350 {
|
|
351 Bufbyte str[MAX_EMCHAR_LEN];
|
|
352 Bufbyte *strptr = str;
|
444
|
353 unsigned int bytes;
|
428
|
354
|
|
355 str[0] = (Bufbyte) ch;
|
444
|
356
|
|
357 for (bytes = REP_BYTES_BY_FIRST_BYTE (ch) - 1; bytes; bytes--)
|
428
|
358 {
|
444
|
359 int c = Lstream_getc (stream);
|
|
360 bufpos_checking_assert (c >= 0);
|
|
361 *++strptr = (Bufbyte) c;
|
428
|
362 }
|
|
363 return charptr_emchar (str);
|
|
364 }
|
|
365
|
|
366 int
|
|
367 Lstream_fput_emchar (Lstream *stream, Emchar ch)
|
|
368 {
|
|
369 Bufbyte str[MAX_EMCHAR_LEN];
|
|
370 Bytecount len = set_charptr_emchar (str, ch);
|
|
371 return Lstream_write (stream, str, len);
|
|
372 }
|
|
373
|
|
374 void
|
|
375 Lstream_funget_emchar (Lstream *stream, Emchar ch)
|
|
376 {
|
|
377 Bufbyte str[MAX_EMCHAR_LEN];
|
|
378 Bytecount len = set_charptr_emchar (str, ch);
|
|
379 Lstream_unread (stream, str, len);
|
|
380 }
|
|
381
|
|
382
|
|
383 /************************************************************************/
|
|
384 /* charset object */
|
|
385 /************************************************************************/
|
|
386
|
|
387 static Lisp_Object
|
|
388 mark_charset (Lisp_Object obj)
|
|
389 {
|
440
|
390 Lisp_Charset *cs = XCHARSET (obj);
|
428
|
391
|
|
392 mark_object (cs->short_name);
|
|
393 mark_object (cs->long_name);
|
|
394 mark_object (cs->doc_string);
|
|
395 mark_object (cs->registry);
|
|
396 mark_object (cs->ccl_program);
|
|
397 return cs->name;
|
|
398 }
|
|
399
|
|
400 static void
|
|
401 print_charset (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
402 {
|
440
|
403 Lisp_Charset *cs = XCHARSET (obj);
|
428
|
404 char buf[200];
|
|
405
|
|
406 if (print_readably)
|
563
|
407 printing_unreadable_object ("#<charset %s 0x%x>",
|
|
408 string_data (XSYMBOL (CHARSET_NAME (cs))->
|
|
409 name),
|
|
410 cs->header.uid);
|
428
|
411
|
|
412 write_c_string ("#<charset ", printcharfun);
|
|
413 print_internal (CHARSET_NAME (cs), printcharfun, 0);
|
|
414 write_c_string (" ", printcharfun);
|
|
415 print_internal (CHARSET_SHORT_NAME (cs), printcharfun, 1);
|
|
416 write_c_string (" ", printcharfun);
|
|
417 print_internal (CHARSET_LONG_NAME (cs), printcharfun, 1);
|
|
418 write_c_string (" ", printcharfun);
|
|
419 print_internal (CHARSET_DOC_STRING (cs), printcharfun, 1);
|
|
420 sprintf (buf, " %s %s cols=%d g%d final='%c' reg=",
|
|
421 CHARSET_TYPE (cs) == CHARSET_TYPE_94 ? "94" :
|
|
422 CHARSET_TYPE (cs) == CHARSET_TYPE_96 ? "96" :
|
|
423 CHARSET_TYPE (cs) == CHARSET_TYPE_94X94 ? "94x94" :
|
|
424 "96x96",
|
|
425 CHARSET_DIRECTION (cs) == CHARSET_LEFT_TO_RIGHT ? "l2r" : "r2l",
|
|
426 CHARSET_COLUMNS (cs),
|
|
427 CHARSET_GRAPHIC (cs),
|
|
428 CHARSET_FINAL (cs));
|
|
429 write_c_string (buf, printcharfun);
|
|
430 print_internal (CHARSET_REGISTRY (cs), printcharfun, 0);
|
|
431 sprintf (buf, " 0x%x>", cs->header.uid);
|
|
432 write_c_string (buf, printcharfun);
|
|
433 }
|
|
434
|
|
435 static const struct lrecord_description charset_description[] = {
|
440
|
436 { XD_LISP_OBJECT, offsetof (Lisp_Charset, name) },
|
|
437 { XD_LISP_OBJECT, offsetof (Lisp_Charset, doc_string) },
|
|
438 { XD_LISP_OBJECT, offsetof (Lisp_Charset, registry) },
|
|
439 { XD_LISP_OBJECT, offsetof (Lisp_Charset, short_name) },
|
|
440 { XD_LISP_OBJECT, offsetof (Lisp_Charset, long_name) },
|
|
441 { XD_LISP_OBJECT, offsetof (Lisp_Charset, reverse_direction_charset) },
|
|
442 { XD_LISP_OBJECT, offsetof (Lisp_Charset, ccl_program) },
|
428
|
443 { XD_END }
|
|
444 };
|
|
445
|
|
446 DEFINE_LRECORD_IMPLEMENTATION ("charset", charset,
|
|
447 mark_charset, print_charset, 0, 0, 0, charset_description,
|
440
|
448 Lisp_Charset);
|
446
|
449
|
428
|
450 /* Make a new charset. */
|
446
|
451 /* #### SJT Should generic properties be allowed? */
|
428
|
452 static Lisp_Object
|
|
453 make_charset (int id, Lisp_Object name, unsigned char rep_bytes,
|
|
454 unsigned char type, unsigned char columns, unsigned char graphic,
|
|
455 Bufbyte final, unsigned char direction, Lisp_Object short_name,
|
|
456 Lisp_Object long_name, Lisp_Object doc,
|
|
457 Lisp_Object reg)
|
|
458 {
|
|
459 Lisp_Object obj;
|
440
|
460 Lisp_Charset *cs = alloc_lcrecord_type (Lisp_Charset, &lrecord_charset);
|
|
461
|
|
462 zero_lcrecord (cs);
|
|
463
|
428
|
464 XSETCHARSET (obj, cs);
|
|
465
|
|
466 CHARSET_ID (cs) = id;
|
|
467 CHARSET_NAME (cs) = name;
|
|
468 CHARSET_SHORT_NAME (cs) = short_name;
|
|
469 CHARSET_LONG_NAME (cs) = long_name;
|
|
470 CHARSET_REP_BYTES (cs) = rep_bytes;
|
|
471 CHARSET_DIRECTION (cs) = direction;
|
|
472 CHARSET_TYPE (cs) = type;
|
|
473 CHARSET_COLUMNS (cs) = columns;
|
|
474 CHARSET_GRAPHIC (cs) = graphic;
|
|
475 CHARSET_FINAL (cs) = final;
|
|
476 CHARSET_DOC_STRING (cs) = doc;
|
|
477 CHARSET_REGISTRY (cs) = reg;
|
|
478 CHARSET_CCL_PROGRAM (cs) = Qnil;
|
|
479 CHARSET_REVERSE_DIRECTION_CHARSET (cs) = Qnil;
|
|
480
|
|
481 CHARSET_DIMENSION (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 ||
|
|
482 CHARSET_TYPE (cs) == CHARSET_TYPE_96) ? 1 : 2;
|
|
483 CHARSET_CHARS (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 ||
|
|
484 CHARSET_TYPE (cs) == CHARSET_TYPE_94X94) ? 94 : 96;
|
|
485
|
|
486 if (final)
|
|
487 {
|
|
488 /* some charsets do not have final characters. This includes
|
|
489 ASCII, Control-1, Composite, and the two faux private
|
|
490 charsets. */
|
|
491 assert (NILP (chlook->charset_by_attributes[type][final][direction]));
|
|
492 chlook->charset_by_attributes[type][final][direction] = obj;
|
|
493 }
|
|
494
|
|
495 assert (NILP (chlook->charset_by_leading_byte[id - 128]));
|
|
496 chlook->charset_by_leading_byte[id - 128] = obj;
|
|
497
|
|
498 /* Some charsets are "faux" and don't have names or really exist at
|
|
499 all except in the leading-byte table. */
|
|
500 if (!NILP (name))
|
|
501 Fputhash (name, obj, Vcharset_hash_table);
|
|
502 return obj;
|
|
503 }
|
|
504
|
|
505 static int
|
|
506 get_unallocated_leading_byte (int dimension)
|
|
507 {
|
|
508 int lb;
|
|
509
|
|
510 if (dimension == 1)
|
|
511 {
|
442
|
512 if (chlook->next_allocated_1_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_1)
|
428
|
513 lb = 0;
|
|
514 else
|
442
|
515 lb = chlook->next_allocated_1_byte_leading_byte++;
|
428
|
516 }
|
|
517 else
|
|
518 {
|
442
|
519 if (chlook->next_allocated_2_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_2)
|
428
|
520 lb = 0;
|
|
521 else
|
442
|
522 lb = chlook->next_allocated_2_byte_leading_byte++;
|
428
|
523 }
|
|
524
|
|
525 if (!lb)
|
563
|
526 invalid_operation
|
428
|
527 ("No more character sets free for this dimension",
|
|
528 make_int (dimension));
|
|
529
|
|
530 return lb;
|
|
531 }
|
|
532
|
|
533
|
|
534 /************************************************************************/
|
|
535 /* Basic charset Lisp functions */
|
|
536 /************************************************************************/
|
|
537
|
|
538 DEFUN ("charsetp", Fcharsetp, 1, 1, 0, /*
|
|
539 Return non-nil if OBJECT is a charset.
|
|
540 */
|
|
541 (object))
|
|
542 {
|
|
543 return CHARSETP (object) ? Qt : Qnil;
|
|
544 }
|
|
545
|
|
546 DEFUN ("find-charset", Ffind_charset, 1, 1, 0, /*
|
|
547 Retrieve the charset of the given name.
|
|
548 If CHARSET-OR-NAME is a charset object, it is simply returned.
|
|
549 Otherwise, CHARSET-OR-NAME should be a symbol. If there is no such charset,
|
|
550 nil is returned. Otherwise the associated charset object is returned.
|
|
551 */
|
|
552 (charset_or_name))
|
|
553 {
|
|
554 if (CHARSETP (charset_or_name))
|
|
555 return charset_or_name;
|
|
556
|
|
557 CHECK_SYMBOL (charset_or_name);
|
|
558 return Fgethash (charset_or_name, Vcharset_hash_table, Qnil);
|
|
559 }
|
|
560
|
|
561 DEFUN ("get-charset", Fget_charset, 1, 1, 0, /*
|
|
562 Retrieve the charset of the given name.
|
|
563 Same as `find-charset' except an error is signalled if there is no such
|
|
564 charset instead of returning nil.
|
|
565 */
|
|
566 (name))
|
|
567 {
|
|
568 Lisp_Object charset = Ffind_charset (name);
|
|
569
|
|
570 if (NILP (charset))
|
563
|
571 invalid_argument ("No such charset", name);
|
428
|
572 return charset;
|
|
573 }
|
|
574
|
|
575 /* We store the charsets in hash tables with the names as the key and the
|
|
576 actual charset object as the value. Occasionally we need to use them
|
|
577 in a list format. These routines provide us with that. */
|
|
578 struct charset_list_closure
|
|
579 {
|
|
580 Lisp_Object *charset_list;
|
|
581 };
|
|
582
|
|
583 static int
|
|
584 add_charset_to_list_mapper (Lisp_Object key, Lisp_Object value,
|
|
585 void *charset_list_closure)
|
|
586 {
|
|
587 /* This function can GC */
|
|
588 struct charset_list_closure *chcl =
|
|
589 (struct charset_list_closure*) charset_list_closure;
|
|
590 Lisp_Object *charset_list = chcl->charset_list;
|
|
591
|
|
592 *charset_list = Fcons (XCHARSET_NAME (value), *charset_list);
|
|
593 return 0;
|
|
594 }
|
|
595
|
|
596 DEFUN ("charset-list", Fcharset_list, 0, 0, 0, /*
|
|
597 Return a list of the names of all defined charsets.
|
|
598 */
|
|
599 ())
|
|
600 {
|
|
601 Lisp_Object charset_list = Qnil;
|
|
602 struct gcpro gcpro1;
|
|
603 struct charset_list_closure charset_list_closure;
|
|
604
|
|
605 GCPRO1 (charset_list);
|
|
606 charset_list_closure.charset_list = &charset_list;
|
|
607 elisp_maphash (add_charset_to_list_mapper, Vcharset_hash_table,
|
|
608 &charset_list_closure);
|
|
609 UNGCPRO;
|
|
610
|
|
611 return charset_list;
|
|
612 }
|
|
613
|
|
614 DEFUN ("charset-name", Fcharset_name, 1, 1, 0, /*
|
444
|
615 Return the name of charset CHARSET.
|
428
|
616 */
|
|
617 (charset))
|
|
618 {
|
|
619 return XCHARSET_NAME (Fget_charset (charset));
|
|
620 }
|
|
621
|
446
|
622 /* #### SJT Should generic properties be allowed? */
|
428
|
623 DEFUN ("make-charset", Fmake_charset, 3, 3, 0, /*
|
|
624 Define a new character set.
|
|
625 This function is for use with Mule support.
|
|
626 NAME is a symbol, the name by which the character set is normally referred.
|
|
627 DOC-STRING is a string describing the character set.
|
|
628 PROPS is a property list, describing the specific nature of the
|
|
629 character set. Recognized properties are:
|
|
630
|
|
631 'short-name Short version of the charset name (ex: Latin-1)
|
|
632 'long-name Long version of the charset name (ex: ISO8859-1 (Latin-1))
|
|
633 'registry A regular expression matching the font registry field for
|
|
634 this character set.
|
|
635 'dimension Number of octets used to index a character in this charset.
|
|
636 Either 1 or 2. Defaults to 1.
|
|
637 'columns Number of columns used to display a character in this charset.
|
|
638 Only used in TTY mode. (Under X, the actual width of a
|
|
639 character can be derived from the font used to display the
|
|
640 characters.) If unspecified, defaults to the dimension
|
|
641 (this is almost always the correct value).
|
|
642 'chars Number of characters in each dimension (94 or 96).
|
|
643 Defaults to 94. Note that if the dimension is 2, the
|
|
644 character set thus described is 94x94 or 96x96.
|
|
645 'final Final byte of ISO 2022 escape sequence. Must be
|
|
646 supplied. Each combination of (DIMENSION, CHARS) defines a
|
|
647 separate namespace for final bytes. Note that ISO
|
|
648 2022 restricts the final byte to the range
|
|
649 0x30 - 0x7E if dimension == 1, and 0x30 - 0x5F if
|
|
650 dimension == 2. Note also that final bytes in the range
|
|
651 0x30 - 0x3F are reserved for user-defined (not official)
|
|
652 character sets.
|
|
653 'graphic 0 (use left half of font on output) or 1 (use right half
|
|
654 of font on output). Defaults to 0. For example, for
|
|
655 a font whose registry is ISO8859-1, the left half
|
|
656 (octets 0x20 - 0x7F) is the `ascii' character set, while
|
|
657 the right half (octets 0xA0 - 0xFF) is the `latin-1'
|
|
658 character set. With 'graphic set to 0, the octets
|
|
659 will have their high bit cleared; with it set to 1,
|
|
660 the octets will have their high bit set.
|
|
661 'direction 'l2r (left-to-right) or 'r2l (right-to-left).
|
|
662 Defaults to 'l2r.
|
|
663 'ccl-program A compiled CCL program used to convert a character in
|
|
664 this charset into an index into the font. This is in
|
|
665 addition to the 'graphic property. The CCL program
|
|
666 is passed the octets of the character, with the high
|
|
667 bit cleared and set depending upon whether the value
|
|
668 of the 'graphic property is 0 or 1.
|
|
669 */
|
|
670 (name, doc_string, props))
|
|
671 {
|
|
672 int id, dimension = 1, chars = 94, graphic = 0, final = 0, columns = -1;
|
|
673 int direction = CHARSET_LEFT_TO_RIGHT;
|
|
674 int type;
|
|
675 Lisp_Object registry = Qnil;
|
|
676 Lisp_Object charset;
|
|
677 Lisp_Object ccl_program = Qnil;
|
|
678 Lisp_Object short_name = Qnil, long_name = Qnil;
|
|
679
|
|
680 CHECK_SYMBOL (name);
|
|
681 if (!NILP (doc_string))
|
|
682 CHECK_STRING (doc_string);
|
|
683
|
|
684 charset = Ffind_charset (name);
|
|
685 if (!NILP (charset))
|
563
|
686 invalid_operation ("Cannot redefine existing charset", name);
|
428
|
687
|
442
|
688 {
|
|
689 EXTERNAL_PROPERTY_LIST_LOOP_3 (keyword, value, props)
|
|
690 {
|
|
691 if (EQ (keyword, Qshort_name))
|
|
692 {
|
|
693 CHECK_STRING (value);
|
|
694 short_name = value;
|
|
695 }
|
428
|
696
|
519
|
697 else if (EQ (keyword, Qlong_name))
|
442
|
698 {
|
|
699 CHECK_STRING (value);
|
|
700 long_name = value;
|
|
701 }
|
428
|
702
|
442
|
703 else if (EQ (keyword, Qdimension))
|
|
704 {
|
|
705 CHECK_INT (value);
|
|
706 dimension = XINT (value);
|
|
707 if (dimension < 1 || dimension > 2)
|
563
|
708 invalid_constant ("Invalid value for 'dimension", value);
|
442
|
709 }
|
428
|
710
|
442
|
711 else if (EQ (keyword, Qchars))
|
|
712 {
|
|
713 CHECK_INT (value);
|
|
714 chars = XINT (value);
|
|
715 if (chars != 94 && chars != 96)
|
563
|
716 invalid_constant ("Invalid value for 'chars", value);
|
442
|
717 }
|
428
|
718
|
442
|
719 else if (EQ (keyword, Qcolumns))
|
|
720 {
|
|
721 CHECK_INT (value);
|
|
722 columns = XINT (value);
|
|
723 if (columns != 1 && columns != 2)
|
563
|
724 invalid_constant ("Invalid value for 'columns", value);
|
442
|
725 }
|
428
|
726
|
442
|
727 else if (EQ (keyword, Qgraphic))
|
|
728 {
|
|
729 CHECK_INT (value);
|
|
730 graphic = XINT (value);
|
|
731 if (graphic < 0 || graphic > 1)
|
563
|
732 invalid_constant ("Invalid value for 'graphic", value);
|
442
|
733 }
|
428
|
734
|
442
|
735 else if (EQ (keyword, Qregistry))
|
|
736 {
|
|
737 CHECK_STRING (value);
|
|
738 registry = value;
|
|
739 }
|
428
|
740
|
442
|
741 else if (EQ (keyword, Qdirection))
|
|
742 {
|
|
743 if (EQ (value, Ql2r))
|
|
744 direction = CHARSET_LEFT_TO_RIGHT;
|
|
745 else if (EQ (value, Qr2l))
|
|
746 direction = CHARSET_RIGHT_TO_LEFT;
|
|
747 else
|
563
|
748 invalid_constant ("Invalid value for 'direction", value);
|
442
|
749 }
|
428
|
750
|
442
|
751 else if (EQ (keyword, Qfinal))
|
|
752 {
|
|
753 CHECK_CHAR_COERCE_INT (value);
|
|
754 final = XCHAR (value);
|
|
755 if (final < '0' || final > '~')
|
563
|
756 invalid_constant ("Invalid value for 'final", value);
|
442
|
757 }
|
428
|
758
|
442
|
759 else if (EQ (keyword, Qccl_program))
|
|
760 {
|
444
|
761 struct ccl_program test_ccl;
|
|
762
|
|
763 if (setup_ccl_program (&test_ccl, value) < 0)
|
563
|
764 invalid_argument ("Invalid value for 'ccl-program", value);
|
442
|
765 ccl_program = value;
|
|
766 }
|
428
|
767
|
442
|
768 else
|
563
|
769 invalid_constant ("Unrecognized property", keyword);
|
442
|
770 }
|
|
771 }
|
428
|
772
|
|
773 if (!final)
|
563
|
774 invalid_argument ("'final must be specified", Qunbound);
|
428
|
775 if (dimension == 2 && final > 0x5F)
|
563
|
776 invalid_constant
|
428
|
777 ("Final must be in the range 0x30 - 0x5F for dimension == 2",
|
|
778 make_char (final));
|
|
779
|
|
780 if (dimension == 1)
|
|
781 type = (chars == 94) ? CHARSET_TYPE_94 : CHARSET_TYPE_96;
|
|
782 else
|
|
783 type = (chars == 94) ? CHARSET_TYPE_94X94 : CHARSET_TYPE_96X96;
|
|
784
|
|
785 if (!NILP (CHARSET_BY_ATTRIBUTES (type, final, CHARSET_LEFT_TO_RIGHT)) ||
|
|
786 !NILP (CHARSET_BY_ATTRIBUTES (type, final, CHARSET_RIGHT_TO_LEFT)))
|
578
|
787 invalid_argument
|
|
788 ("Character set already defined for this DIMENSION/CHARS/FINAL combo",
|
565
|
789 Qunbound);
|
428
|
790
|
|
791 id = get_unallocated_leading_byte (dimension);
|
|
792
|
|
793 if (NILP (doc_string))
|
|
794 doc_string = build_string ("");
|
|
795
|
|
796 if (NILP (registry))
|
|
797 registry = build_string ("");
|
|
798
|
|
799 if (NILP (short_name))
|
|
800 XSETSTRING (short_name, XSYMBOL (name)->name);
|
|
801
|
|
802 if (NILP (long_name))
|
|
803 long_name = doc_string;
|
|
804
|
|
805 if (columns == -1)
|
|
806 columns = dimension;
|
|
807 charset = make_charset (id, name, dimension + 2, type, columns, graphic,
|
|
808 final, direction, short_name, long_name, doc_string, registry);
|
|
809 if (!NILP (ccl_program))
|
|
810 XCHARSET_CCL_PROGRAM (charset) = ccl_program;
|
|
811 return charset;
|
|
812 }
|
|
813
|
|
814 DEFUN ("make-reverse-direction-charset", Fmake_reverse_direction_charset,
|
|
815 2, 2, 0, /*
|
|
816 Make a charset equivalent to CHARSET but which goes in the opposite direction.
|
|
817 NEW-NAME is the name of the new charset. Return the new charset.
|
|
818 */
|
|
819 (charset, new_name))
|
|
820 {
|
|
821 Lisp_Object new_charset = Qnil;
|
|
822 int id, dimension, columns, graphic, final;
|
|
823 int direction, type;
|
|
824 Lisp_Object registry, doc_string, short_name, long_name;
|
440
|
825 Lisp_Charset *cs;
|
428
|
826
|
|
827 charset = Fget_charset (charset);
|
|
828 if (!NILP (XCHARSET_REVERSE_DIRECTION_CHARSET (charset)))
|
563
|
829 invalid_operation ("Charset already has reverse-direction charset",
|
428
|
830 charset);
|
|
831
|
|
832 CHECK_SYMBOL (new_name);
|
|
833 if (!NILP (Ffind_charset (new_name)))
|
563
|
834 invalid_operation ("Cannot redefine existing charset", new_name);
|
428
|
835
|
|
836 cs = XCHARSET (charset);
|
|
837
|
|
838 type = CHARSET_TYPE (cs);
|
|
839 columns = CHARSET_COLUMNS (cs);
|
|
840 dimension = CHARSET_DIMENSION (cs);
|
|
841 id = get_unallocated_leading_byte (dimension);
|
|
842
|
|
843 graphic = CHARSET_GRAPHIC (cs);
|
|
844 final = CHARSET_FINAL (cs);
|
|
845 direction = CHARSET_RIGHT_TO_LEFT;
|
|
846 if (CHARSET_DIRECTION (cs) == CHARSET_RIGHT_TO_LEFT)
|
|
847 direction = CHARSET_LEFT_TO_RIGHT;
|
|
848 doc_string = CHARSET_DOC_STRING (cs);
|
|
849 short_name = CHARSET_SHORT_NAME (cs);
|
|
850 long_name = CHARSET_LONG_NAME (cs);
|
|
851 registry = CHARSET_REGISTRY (cs);
|
|
852
|
|
853 new_charset = make_charset (id, new_name, dimension + 2, type, columns,
|
|
854 graphic, final, direction, short_name, long_name,
|
|
855 doc_string, registry);
|
|
856
|
|
857 CHARSET_REVERSE_DIRECTION_CHARSET (cs) = new_charset;
|
|
858 XCHARSET_REVERSE_DIRECTION_CHARSET (new_charset) = charset;
|
|
859
|
|
860 return new_charset;
|
|
861 }
|
|
862
|
|
863 /* #### Reverse direction charsets not yet implemented. */
|
|
864 #if 0
|
|
865 DEFUN ("charset-reverse-direction-charset", Fcharset_reverse_direction_charset,
|
|
866 1, 1, 0, /*
|
|
867 Return the reverse-direction charset parallel to CHARSET, if any.
|
|
868 This is the charset with the same properties (in particular, the same
|
|
869 dimension, number of characters per dimension, and final byte) as
|
|
870 CHARSET but whose characters are displayed in the opposite direction.
|
|
871 */
|
|
872 (charset))
|
|
873 {
|
|
874 charset = Fget_charset (charset);
|
|
875 return XCHARSET_REVERSE_DIRECTION_CHARSET (charset);
|
|
876 }
|
|
877 #endif
|
|
878
|
|
879 DEFUN ("charset-from-attributes", Fcharset_from_attributes, 3, 4, 0, /*
|
|
880 Return a charset with the given DIMENSION, CHARS, FINAL, and DIRECTION.
|
|
881 If DIRECTION is omitted, both directions will be checked (left-to-right
|
|
882 will be returned if character sets exist for both directions).
|
|
883 */
|
|
884 (dimension, chars, final, direction))
|
|
885 {
|
|
886 int dm, ch, fi, di = -1;
|
|
887 int type;
|
|
888 Lisp_Object obj = Qnil;
|
|
889
|
|
890 CHECK_INT (dimension);
|
|
891 dm = XINT (dimension);
|
|
892 if (dm < 1 || dm > 2)
|
563
|
893 invalid_constant ("Invalid value for DIMENSION", dimension);
|
428
|
894
|
|
895 CHECK_INT (chars);
|
|
896 ch = XINT (chars);
|
|
897 if (ch != 94 && ch != 96)
|
563
|
898 invalid_constant ("Invalid value for CHARS", chars);
|
428
|
899
|
|
900 CHECK_CHAR_COERCE_INT (final);
|
|
901 fi = XCHAR (final);
|
|
902 if (fi < '0' || fi > '~')
|
563
|
903 invalid_constant ("Invalid value for FINAL", final);
|
428
|
904
|
|
905 if (EQ (direction, Ql2r))
|
|
906 di = CHARSET_LEFT_TO_RIGHT;
|
|
907 else if (EQ (direction, Qr2l))
|
|
908 di = CHARSET_RIGHT_TO_LEFT;
|
|
909 else if (!NILP (direction))
|
563
|
910 invalid_constant ("Invalid value for DIRECTION", direction);
|
428
|
911
|
|
912 if (dm == 2 && fi > 0x5F)
|
563
|
913 invalid_constant
|
428
|
914 ("Final must be in the range 0x30 - 0x5F for dimension == 2", final);
|
|
915
|
|
916 if (dm == 1)
|
|
917 type = (ch == 94) ? CHARSET_TYPE_94 : CHARSET_TYPE_96;
|
|
918 else
|
|
919 type = (ch == 94) ? CHARSET_TYPE_94X94 : CHARSET_TYPE_96X96;
|
|
920
|
|
921 if (di == -1)
|
|
922 {
|
|
923 obj = CHARSET_BY_ATTRIBUTES (type, fi, CHARSET_LEFT_TO_RIGHT);
|
|
924 if (NILP (obj))
|
|
925 obj = CHARSET_BY_ATTRIBUTES (type, fi, CHARSET_RIGHT_TO_LEFT);
|
|
926 }
|
|
927 else
|
|
928 obj = CHARSET_BY_ATTRIBUTES (type, fi, di);
|
|
929
|
|
930 if (CHARSETP (obj))
|
|
931 return XCHARSET_NAME (obj);
|
|
932 return obj;
|
|
933 }
|
|
934
|
|
935 DEFUN ("charset-short-name", Fcharset_short_name, 1, 1, 0, /*
|
|
936 Return short name of CHARSET.
|
|
937 */
|
|
938 (charset))
|
|
939 {
|
|
940 return XCHARSET_SHORT_NAME (Fget_charset (charset));
|
|
941 }
|
|
942
|
|
943 DEFUN ("charset-long-name", Fcharset_long_name, 1, 1, 0, /*
|
|
944 Return long name of CHARSET.
|
|
945 */
|
|
946 (charset))
|
|
947 {
|
|
948 return XCHARSET_LONG_NAME (Fget_charset (charset));
|
|
949 }
|
|
950
|
|
951 DEFUN ("charset-description", Fcharset_description, 1, 1, 0, /*
|
|
952 Return description of CHARSET.
|
|
953 */
|
|
954 (charset))
|
|
955 {
|
|
956 return XCHARSET_DOC_STRING (Fget_charset (charset));
|
|
957 }
|
|
958
|
|
959 DEFUN ("charset-dimension", Fcharset_dimension, 1, 1, 0, /*
|
|
960 Return dimension of CHARSET.
|
|
961 */
|
|
962 (charset))
|
|
963 {
|
|
964 return make_int (XCHARSET_DIMENSION (Fget_charset (charset)));
|
|
965 }
|
|
966
|
|
967 DEFUN ("charset-property", Fcharset_property, 2, 2, 0, /*
|
446
|
968 Return property PROP of CHARSET, a charset object or symbol naming a charset.
|
428
|
969 Recognized properties are those listed in `make-charset', as well as
|
|
970 'name and 'doc-string.
|
|
971 */
|
|
972 (charset, prop))
|
|
973 {
|
440
|
974 Lisp_Charset *cs;
|
428
|
975
|
|
976 charset = Fget_charset (charset);
|
|
977 cs = XCHARSET (charset);
|
|
978
|
|
979 CHECK_SYMBOL (prop);
|
|
980 if (EQ (prop, Qname)) return CHARSET_NAME (cs);
|
|
981 if (EQ (prop, Qshort_name)) return CHARSET_SHORT_NAME (cs);
|
|
982 if (EQ (prop, Qlong_name)) return CHARSET_LONG_NAME (cs);
|
|
983 if (EQ (prop, Qdoc_string)) return CHARSET_DOC_STRING (cs);
|
|
984 if (EQ (prop, Qdimension)) return make_int (CHARSET_DIMENSION (cs));
|
|
985 if (EQ (prop, Qcolumns)) return make_int (CHARSET_COLUMNS (cs));
|
|
986 if (EQ (prop, Qgraphic)) return make_int (CHARSET_GRAPHIC (cs));
|
|
987 if (EQ (prop, Qfinal)) return make_char (CHARSET_FINAL (cs));
|
|
988 if (EQ (prop, Qchars)) return make_int (CHARSET_CHARS (cs));
|
|
989 if (EQ (prop, Qregistry)) return CHARSET_REGISTRY (cs);
|
|
990 if (EQ (prop, Qccl_program)) return CHARSET_CCL_PROGRAM (cs);
|
|
991 if (EQ (prop, Qdirection))
|
|
992 return CHARSET_DIRECTION (cs) == CHARSET_LEFT_TO_RIGHT ? Ql2r : Qr2l;
|
|
993 if (EQ (prop, Qreverse_direction_charset))
|
|
994 {
|
|
995 Lisp_Object obj = CHARSET_REVERSE_DIRECTION_CHARSET (cs);
|
446
|
996 /* #### Is this translation OK? If so, error checking sufficient? */
|
|
997 return CHARSETP (obj) ? XCHARSET_NAME (obj) : obj;
|
428
|
998 }
|
563
|
999 invalid_constant ("Unrecognized charset property name", prop);
|
428
|
1000 return Qnil; /* not reached */
|
|
1001 }
|
|
1002
|
|
1003 DEFUN ("charset-id", Fcharset_id, 1, 1, 0, /*
|
|
1004 Return charset identification number of CHARSET.
|
|
1005 */
|
|
1006 (charset))
|
|
1007 {
|
|
1008 return make_int(XCHARSET_LEADING_BYTE (Fget_charset (charset)));
|
|
1009 }
|
|
1010
|
|
1011 /* #### We need to figure out which properties we really want to
|
|
1012 allow to be set. */
|
|
1013
|
|
1014 DEFUN ("set-charset-ccl-program", Fset_charset_ccl_program, 2, 2, 0, /*
|
|
1015 Set the 'ccl-program property of CHARSET to CCL-PROGRAM.
|
|
1016 */
|
|
1017 (charset, ccl_program))
|
|
1018 {
|
444
|
1019 struct ccl_program test_ccl;
|
|
1020
|
428
|
1021 charset = Fget_charset (charset);
|
444
|
1022 if (setup_ccl_program (&test_ccl, ccl_program) < 0)
|
563
|
1023 invalid_argument ("Invalid ccl-program", ccl_program);
|
428
|
1024 XCHARSET_CCL_PROGRAM (charset) = ccl_program;
|
510
|
1025 face_property_was_changed (Vdefault_face, Qfont, Qglobal);
|
428
|
1026 return Qnil;
|
|
1027 }
|
|
1028
|
|
1029 static void
|
|
1030 invalidate_charset_font_caches (Lisp_Object charset)
|
|
1031 {
|
|
1032 /* Invalidate font cache entries for charset on all devices. */
|
|
1033 Lisp_Object devcons, concons, hash_table;
|
|
1034 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
1035 {
|
|
1036 struct device *d = XDEVICE (XCAR (devcons));
|
|
1037 hash_table = Fgethash (charset, d->charset_font_cache, Qunbound);
|
|
1038 if (!UNBOUNDP (hash_table))
|
|
1039 Fclrhash (hash_table);
|
|
1040 }
|
|
1041 }
|
|
1042
|
|
1043 /* Japanese folks may want to (set-charset-registry 'ascii "jisx0201") */
|
|
1044 DEFUN ("set-charset-registry", Fset_charset_registry, 2, 2, 0, /*
|
|
1045 Set the 'registry property of CHARSET to REGISTRY.
|
|
1046 */
|
|
1047 (charset, registry))
|
|
1048 {
|
|
1049 charset = Fget_charset (charset);
|
|
1050 CHECK_STRING (registry);
|
|
1051 XCHARSET_REGISTRY (charset) = registry;
|
|
1052 invalidate_charset_font_caches (charset);
|
|
1053 face_property_was_changed (Vdefault_face, Qfont, Qglobal);
|
|
1054 return Qnil;
|
|
1055 }
|
|
1056
|
|
1057
|
|
1058 /************************************************************************/
|
|
1059 /* Lisp primitives for working with characters */
|
|
1060 /************************************************************************/
|
|
1061
|
|
1062 DEFUN ("make-char", Fmake_char, 2, 3, 0, /*
|
|
1063 Make a character from CHARSET and octets ARG1 and ARG2.
|
|
1064 ARG2 is required only for characters from two-dimensional charsets.
|
|
1065 For example, (make-char 'latin-iso8859-2 185) will return the Latin 2
|
|
1066 character s with caron.
|
|
1067 */
|
|
1068 (charset, arg1, arg2))
|
|
1069 {
|
440
|
1070 Lisp_Charset *cs;
|
428
|
1071 int a1, a2;
|
|
1072 int lowlim, highlim;
|
|
1073
|
|
1074 charset = Fget_charset (charset);
|
|
1075 cs = XCHARSET (charset);
|
|
1076
|
|
1077 if (EQ (charset, Vcharset_ascii)) lowlim = 0, highlim = 127;
|
|
1078 else if (EQ (charset, Vcharset_control_1)) lowlim = 0, highlim = 31;
|
|
1079 else if (CHARSET_CHARS (cs) == 94) lowlim = 33, highlim = 126;
|
|
1080 else /* CHARSET_CHARS (cs) == 96) */ lowlim = 32, highlim = 127;
|
|
1081
|
|
1082 CHECK_INT (arg1);
|
|
1083 /* It is useful (and safe, according to Olivier Galibert) to strip
|
442
|
1084 the 8th bit off ARG1 and ARG2 because it allows programmers to
|
428
|
1085 write (make-char 'latin-iso8859-2 CODE) where code is the actual
|
|
1086 Latin 2 code of the character. */
|
|
1087 a1 = XINT (arg1) & 0x7f;
|
|
1088 if (a1 < lowlim || a1 > highlim)
|
|
1089 args_out_of_range_3 (arg1, make_int (lowlim), make_int (highlim));
|
|
1090
|
|
1091 if (CHARSET_DIMENSION (cs) == 1)
|
|
1092 {
|
|
1093 if (!NILP (arg2))
|
563
|
1094 invalid_argument
|
428
|
1095 ("Charset is of dimension one; second octet must be nil", arg2);
|
|
1096 return make_char (MAKE_CHAR (charset, a1, 0));
|
|
1097 }
|
|
1098
|
|
1099 CHECK_INT (arg2);
|
|
1100 a2 = XINT (arg2) & 0x7f;
|
|
1101 if (a2 < lowlim || a2 > highlim)
|
|
1102 args_out_of_range_3 (arg2, make_int (lowlim), make_int (highlim));
|
|
1103
|
|
1104 return make_char (MAKE_CHAR (charset, a1, a2));
|
|
1105 }
|
|
1106
|
|
1107 DEFUN ("char-charset", Fchar_charset, 1, 1, 0, /*
|
444
|
1108 Return the character set of CHARACTER.
|
428
|
1109 */
|
444
|
1110 (character))
|
428
|
1111 {
|
444
|
1112 CHECK_CHAR_COERCE_INT (character);
|
428
|
1113
|
|
1114 return XCHARSET_NAME (CHARSET_BY_LEADING_BYTE
|
444
|
1115 (CHAR_LEADING_BYTE (XCHAR (character))));
|
428
|
1116 }
|
|
1117
|
438
|
1118 DEFUN ("char-octet", Fchar_octet, 1, 2, 0, /*
|
444
|
1119 Return the octet numbered N (should be 0 or 1) of CHARACTER.
|
438
|
1120 N defaults to 0 if omitted.
|
|
1121 */
|
444
|
1122 (character, n))
|
438
|
1123 {
|
|
1124 Lisp_Object charset;
|
|
1125 int octet0, octet1;
|
|
1126
|
444
|
1127 CHECK_CHAR_COERCE_INT (character);
|
438
|
1128
|
444
|
1129 BREAKUP_CHAR (XCHAR (character), charset, octet0, octet1);
|
438
|
1130
|
|
1131 if (NILP (n) || EQ (n, Qzero))
|
|
1132 return make_int (octet0);
|
|
1133 else if (EQ (n, make_int (1)))
|
|
1134 return make_int (octet1);
|
|
1135 else
|
563
|
1136 invalid_constant ("Octet number must be 0 or 1", n);
|
438
|
1137 }
|
|
1138
|
428
|
1139 DEFUN ("split-char", Fsplit_char, 1, 1, 0, /*
|
444
|
1140 Return list of charset and one or two position-codes of CHARACTER.
|
428
|
1141 */
|
|
1142 (character))
|
|
1143 {
|
|
1144 /* This function can GC */
|
|
1145 struct gcpro gcpro1, gcpro2;
|
|
1146 Lisp_Object charset = Qnil;
|
|
1147 Lisp_Object rc = Qnil;
|
|
1148 int c1, c2;
|
|
1149
|
|
1150 GCPRO2 (charset, rc);
|
|
1151 CHECK_CHAR_COERCE_INT (character);
|
|
1152
|
|
1153 BREAKUP_CHAR (XCHAR (character), charset, c1, c2);
|
|
1154
|
|
1155 if (XCHARSET_DIMENSION (Fget_charset (charset)) == 2)
|
|
1156 {
|
|
1157 rc = list3 (XCHARSET_NAME (charset), make_int (c1), make_int (c2));
|
|
1158 }
|
|
1159 else
|
|
1160 {
|
|
1161 rc = list2 (XCHARSET_NAME (charset), make_int (c1));
|
|
1162 }
|
|
1163 UNGCPRO;
|
|
1164
|
|
1165 return rc;
|
|
1166 }
|
|
1167
|
|
1168
|
|
1169 #ifdef ENABLE_COMPOSITE_CHARS
|
|
1170 /************************************************************************/
|
|
1171 /* composite character functions */
|
|
1172 /************************************************************************/
|
|
1173
|
|
1174 Emchar
|
|
1175 lookup_composite_char (Bufbyte *str, int len)
|
|
1176 {
|
|
1177 Lisp_Object lispstr = make_string (str, len);
|
|
1178 Lisp_Object ch = Fgethash (lispstr,
|
|
1179 Vcomposite_char_string2char_hash_table,
|
|
1180 Qunbound);
|
|
1181 Emchar emch;
|
|
1182
|
|
1183 if (UNBOUNDP (ch))
|
|
1184 {
|
|
1185 if (composite_char_row_next >= 128)
|
563
|
1186 invalid_operation ("No more composite chars available", lispstr);
|
428
|
1187 emch = MAKE_CHAR (Vcharset_composite, composite_char_row_next,
|
|
1188 composite_char_col_next);
|
|
1189 Fputhash (make_char (emch), lispstr,
|
|
1190 Vcomposite_char_char2string_hash_table);
|
|
1191 Fputhash (lispstr, make_char (emch),
|
|
1192 Vcomposite_char_string2char_hash_table);
|
|
1193 composite_char_col_next++;
|
|
1194 if (composite_char_col_next >= 128)
|
|
1195 {
|
|
1196 composite_char_col_next = 32;
|
|
1197 composite_char_row_next++;
|
|
1198 }
|
|
1199 }
|
|
1200 else
|
|
1201 emch = XCHAR (ch);
|
|
1202 return emch;
|
|
1203 }
|
|
1204
|
|
1205 Lisp_Object
|
|
1206 composite_char_string (Emchar ch)
|
|
1207 {
|
|
1208 Lisp_Object str = Fgethash (make_char (ch),
|
|
1209 Vcomposite_char_char2string_hash_table,
|
|
1210 Qunbound);
|
|
1211 assert (!UNBOUNDP (str));
|
|
1212 return str;
|
|
1213 }
|
|
1214
|
|
1215 xxDEFUN ("make-composite-char", Fmake_composite_char, 1, 1, 0, /*
|
|
1216 Convert a string into a single composite character.
|
|
1217 The character is the result of overstriking all the characters in
|
|
1218 the string.
|
|
1219 */
|
|
1220 (string))
|
|
1221 {
|
|
1222 CHECK_STRING (string);
|
|
1223 return make_char (lookup_composite_char (XSTRING_DATA (string),
|
|
1224 XSTRING_LENGTH (string)));
|
|
1225 }
|
|
1226
|
|
1227 xxDEFUN ("composite-char-string", Fcomposite_char_string, 1, 1, 0, /*
|
|
1228 Return a string of the characters comprising a composite character.
|
|
1229 */
|
|
1230 (ch))
|
|
1231 {
|
|
1232 Emchar emch;
|
|
1233
|
|
1234 CHECK_CHAR (ch);
|
|
1235 emch = XCHAR (ch);
|
|
1236 if (CHAR_LEADING_BYTE (emch) != LEADING_BYTE_COMPOSITE)
|
563
|
1237 invalid_argument ("Must be composite char", ch);
|
428
|
1238 return composite_char_string (emch);
|
|
1239 }
|
|
1240 #endif /* ENABLE_COMPOSITE_CHARS */
|
|
1241
|
|
1242
|
|
1243 /************************************************************************/
|
|
1244 /* initialization */
|
|
1245 /************************************************************************/
|
|
1246
|
|
1247 void
|
|
1248 syms_of_mule_charset (void)
|
|
1249 {
|
442
|
1250 INIT_LRECORD_IMPLEMENTATION (charset);
|
|
1251
|
428
|
1252 DEFSUBR (Fcharsetp);
|
|
1253 DEFSUBR (Ffind_charset);
|
|
1254 DEFSUBR (Fget_charset);
|
|
1255 DEFSUBR (Fcharset_list);
|
|
1256 DEFSUBR (Fcharset_name);
|
|
1257 DEFSUBR (Fmake_charset);
|
|
1258 DEFSUBR (Fmake_reverse_direction_charset);
|
|
1259 /* DEFSUBR (Freverse_direction_charset); */
|
|
1260 DEFSUBR (Fcharset_from_attributes);
|
|
1261 DEFSUBR (Fcharset_short_name);
|
|
1262 DEFSUBR (Fcharset_long_name);
|
|
1263 DEFSUBR (Fcharset_description);
|
|
1264 DEFSUBR (Fcharset_dimension);
|
|
1265 DEFSUBR (Fcharset_property);
|
|
1266 DEFSUBR (Fcharset_id);
|
|
1267 DEFSUBR (Fset_charset_ccl_program);
|
|
1268 DEFSUBR (Fset_charset_registry);
|
|
1269
|
|
1270 DEFSUBR (Fmake_char);
|
|
1271 DEFSUBR (Fchar_charset);
|
438
|
1272 DEFSUBR (Fchar_octet);
|
428
|
1273 DEFSUBR (Fsplit_char);
|
|
1274
|
|
1275 #ifdef ENABLE_COMPOSITE_CHARS
|
|
1276 DEFSUBR (Fmake_composite_char);
|
|
1277 DEFSUBR (Fcomposite_char_string);
|
|
1278 #endif
|
|
1279
|
563
|
1280 DEFSYMBOL (Qcharsetp);
|
|
1281 DEFSYMBOL (Qregistry);
|
|
1282 DEFSYMBOL (Qfinal);
|
|
1283 DEFSYMBOL (Qgraphic);
|
|
1284 DEFSYMBOL (Qdirection);
|
|
1285 DEFSYMBOL (Qreverse_direction_charset);
|
|
1286 DEFSYMBOL (Qshort_name);
|
|
1287 DEFSYMBOL (Qlong_name);
|
428
|
1288
|
563
|
1289 DEFSYMBOL (Ql2r);
|
|
1290 DEFSYMBOL (Qr2l);
|
428
|
1291
|
|
1292 /* Charsets, compatible with FSF 20.3
|
|
1293 Naming convention is Script-Charset[-Edition] */
|
563
|
1294 DEFSYMBOL (Qascii);
|
|
1295 DEFSYMBOL (Qcontrol_1);
|
|
1296 DEFSYMBOL (Qlatin_iso8859_1);
|
|
1297 DEFSYMBOL (Qlatin_iso8859_2);
|
|
1298 DEFSYMBOL (Qlatin_iso8859_3);
|
|
1299 DEFSYMBOL (Qlatin_iso8859_4);
|
|
1300 DEFSYMBOL (Qthai_tis620);
|
|
1301 DEFSYMBOL (Qgreek_iso8859_7);
|
|
1302 DEFSYMBOL (Qarabic_iso8859_6);
|
|
1303 DEFSYMBOL (Qhebrew_iso8859_8);
|
|
1304 DEFSYMBOL (Qkatakana_jisx0201);
|
|
1305 DEFSYMBOL (Qlatin_jisx0201);
|
|
1306 DEFSYMBOL (Qcyrillic_iso8859_5);
|
|
1307 DEFSYMBOL (Qlatin_iso8859_9);
|
|
1308 DEFSYMBOL (Qjapanese_jisx0208_1978);
|
|
1309 DEFSYMBOL (Qchinese_gb2312);
|
|
1310 DEFSYMBOL (Qjapanese_jisx0208);
|
|
1311 DEFSYMBOL (Qkorean_ksc5601);
|
|
1312 DEFSYMBOL (Qjapanese_jisx0212);
|
|
1313 DEFSYMBOL (Qchinese_cns11643_1);
|
|
1314 DEFSYMBOL (Qchinese_cns11643_2);
|
|
1315 DEFSYMBOL (Qchinese_big5_1);
|
|
1316 DEFSYMBOL (Qchinese_big5_2);
|
428
|
1317
|
563
|
1318 DEFSYMBOL (Qcomposite);
|
428
|
1319 }
|
|
1320
|
|
1321 void
|
|
1322 vars_of_mule_charset (void)
|
|
1323 {
|
|
1324 int i, j, k;
|
|
1325
|
452
|
1326 chlook = xnew_and_zero (struct charset_lookup); /* zero for Purify. */
|
|
1327 dump_add_root_struct_ptr (&chlook, &charset_lookup_description);
|
428
|
1328
|
|
1329 /* Table of charsets indexed by leading byte. */
|
|
1330 for (i = 0; i < countof (chlook->charset_by_leading_byte); i++)
|
|
1331 chlook->charset_by_leading_byte[i] = Qnil;
|
|
1332
|
|
1333 /* Table of charsets indexed by type/final-byte/direction. */
|
|
1334 for (i = 0; i < countof (chlook->charset_by_attributes); i++)
|
|
1335 for (j = 0; j < countof (chlook->charset_by_attributes[0]); j++)
|
|
1336 for (k = 0; k < countof (chlook->charset_by_attributes[0][0]); k++)
|
|
1337 chlook->charset_by_attributes[i][j][k] = Qnil;
|
|
1338
|
442
|
1339 chlook->next_allocated_1_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_1;
|
|
1340 chlook->next_allocated_2_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_2;
|
428
|
1341 }
|
|
1342
|
|
1343 void
|
|
1344 complex_vars_of_mule_charset (void)
|
|
1345 {
|
|
1346 staticpro (&Vcharset_hash_table);
|
|
1347 Vcharset_hash_table =
|
|
1348 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
|
|
1349
|
|
1350 /* Predefined character sets. We store them into variables for
|
|
1351 ease of access. */
|
|
1352
|
|
1353 staticpro (&Vcharset_ascii);
|
|
1354 Vcharset_ascii =
|
|
1355 make_charset (LEADING_BYTE_ASCII, Qascii, 1,
|
|
1356 CHARSET_TYPE_94, 1, 0, 'B',
|
|
1357 CHARSET_LEFT_TO_RIGHT,
|
|
1358 build_string ("ASCII"),
|
|
1359 build_string ("ASCII)"),
|
|
1360 build_string ("ASCII (ISO646 IRV)"),
|
|
1361 build_string ("\\(iso8859-[0-9]*\\|-ascii\\)"));
|
|
1362 staticpro (&Vcharset_control_1);
|
|
1363 Vcharset_control_1 =
|
|
1364 make_charset (LEADING_BYTE_CONTROL_1, Qcontrol_1, 2,
|
|
1365 CHARSET_TYPE_94, 1, 1, 0,
|
|
1366 CHARSET_LEFT_TO_RIGHT,
|
|
1367 build_string ("C1"),
|
|
1368 build_string ("Control characters"),
|
|
1369 build_string ("Control characters 128-191"),
|
|
1370 build_string (""));
|
|
1371 staticpro (&Vcharset_latin_iso8859_1);
|
|
1372 Vcharset_latin_iso8859_1 =
|
|
1373 make_charset (LEADING_BYTE_LATIN_ISO8859_1, Qlatin_iso8859_1, 2,
|
|
1374 CHARSET_TYPE_96, 1, 1, 'A',
|
|
1375 CHARSET_LEFT_TO_RIGHT,
|
|
1376 build_string ("Latin-1"),
|
|
1377 build_string ("ISO8859-1 (Latin-1)"),
|
|
1378 build_string ("ISO8859-1 (Latin-1)"),
|
|
1379 build_string ("iso8859-1"));
|
|
1380 staticpro (&Vcharset_latin_iso8859_2);
|
|
1381 Vcharset_latin_iso8859_2 =
|
|
1382 make_charset (LEADING_BYTE_LATIN_ISO8859_2, Qlatin_iso8859_2, 2,
|
|
1383 CHARSET_TYPE_96, 1, 1, 'B',
|
|
1384 CHARSET_LEFT_TO_RIGHT,
|
|
1385 build_string ("Latin-2"),
|
|
1386 build_string ("ISO8859-2 (Latin-2)"),
|
|
1387 build_string ("ISO8859-2 (Latin-2)"),
|
|
1388 build_string ("iso8859-2"));
|
|
1389 staticpro (&Vcharset_latin_iso8859_3);
|
|
1390 Vcharset_latin_iso8859_3 =
|
|
1391 make_charset (LEADING_BYTE_LATIN_ISO8859_3, Qlatin_iso8859_3, 2,
|
|
1392 CHARSET_TYPE_96, 1, 1, 'C',
|
|
1393 CHARSET_LEFT_TO_RIGHT,
|
|
1394 build_string ("Latin-3"),
|
|
1395 build_string ("ISO8859-3 (Latin-3)"),
|
|
1396 build_string ("ISO8859-3 (Latin-3)"),
|
|
1397 build_string ("iso8859-3"));
|
|
1398 staticpro (&Vcharset_latin_iso8859_4);
|
|
1399 Vcharset_latin_iso8859_4 =
|
|
1400 make_charset (LEADING_BYTE_LATIN_ISO8859_4, Qlatin_iso8859_4, 2,
|
|
1401 CHARSET_TYPE_96, 1, 1, 'D',
|
|
1402 CHARSET_LEFT_TO_RIGHT,
|
|
1403 build_string ("Latin-4"),
|
|
1404 build_string ("ISO8859-4 (Latin-4)"),
|
|
1405 build_string ("ISO8859-4 (Latin-4)"),
|
|
1406 build_string ("iso8859-4"));
|
|
1407 staticpro (&Vcharset_thai_tis620);
|
|
1408 Vcharset_thai_tis620 =
|
|
1409 make_charset (LEADING_BYTE_THAI_TIS620, Qthai_tis620, 2,
|
|
1410 CHARSET_TYPE_96, 1, 1, 'T',
|
|
1411 CHARSET_LEFT_TO_RIGHT,
|
|
1412 build_string ("TIS620"),
|
|
1413 build_string ("TIS620 (Thai)"),
|
|
1414 build_string ("TIS620.2529 (Thai)"),
|
|
1415 build_string ("tis620"));
|
|
1416 staticpro (&Vcharset_greek_iso8859_7);
|
|
1417 Vcharset_greek_iso8859_7 =
|
|
1418 make_charset (LEADING_BYTE_GREEK_ISO8859_7, Qgreek_iso8859_7, 2,
|
|
1419 CHARSET_TYPE_96, 1, 1, 'F',
|
|
1420 CHARSET_LEFT_TO_RIGHT,
|
|
1421 build_string ("ISO8859-7"),
|
|
1422 build_string ("ISO8859-7 (Greek)"),
|
|
1423 build_string ("ISO8859-7 (Greek)"),
|
|
1424 build_string ("iso8859-7"));
|
|
1425 staticpro (&Vcharset_arabic_iso8859_6);
|
|
1426 Vcharset_arabic_iso8859_6 =
|
|
1427 make_charset (LEADING_BYTE_ARABIC_ISO8859_6, Qarabic_iso8859_6, 2,
|
|
1428 CHARSET_TYPE_96, 1, 1, 'G',
|
|
1429 CHARSET_RIGHT_TO_LEFT,
|
|
1430 build_string ("ISO8859-6"),
|
|
1431 build_string ("ISO8859-6 (Arabic)"),
|
|
1432 build_string ("ISO8859-6 (Arabic)"),
|
|
1433 build_string ("iso8859-6"));
|
|
1434 staticpro (&Vcharset_hebrew_iso8859_8);
|
|
1435 Vcharset_hebrew_iso8859_8 =
|
|
1436 make_charset (LEADING_BYTE_HEBREW_ISO8859_8, Qhebrew_iso8859_8, 2,
|
|
1437 CHARSET_TYPE_96, 1, 1, 'H',
|
|
1438 CHARSET_RIGHT_TO_LEFT,
|
|
1439 build_string ("ISO8859-8"),
|
|
1440 build_string ("ISO8859-8 (Hebrew)"),
|
|
1441 build_string ("ISO8859-8 (Hebrew)"),
|
|
1442 build_string ("iso8859-8"));
|
|
1443 staticpro (&Vcharset_katakana_jisx0201);
|
|
1444 Vcharset_katakana_jisx0201 =
|
|
1445 make_charset (LEADING_BYTE_KATAKANA_JISX0201, Qkatakana_jisx0201, 2,
|
|
1446 CHARSET_TYPE_94, 1, 1, 'I',
|
|
1447 CHARSET_LEFT_TO_RIGHT,
|
|
1448 build_string ("JISX0201 Kana"),
|
|
1449 build_string ("JISX0201.1976 (Japanese Kana)"),
|
|
1450 build_string ("JISX0201.1976 Japanese Kana"),
|
|
1451 build_string ("jisx0201.1976"));
|
|
1452 staticpro (&Vcharset_latin_jisx0201);
|
|
1453 Vcharset_latin_jisx0201 =
|
|
1454 make_charset (LEADING_BYTE_LATIN_JISX0201, Qlatin_jisx0201, 2,
|
|
1455 CHARSET_TYPE_94, 1, 0, 'J',
|
|
1456 CHARSET_LEFT_TO_RIGHT,
|
|
1457 build_string ("JISX0201 Roman"),
|
|
1458 build_string ("JISX0201.1976 (Japanese Roman)"),
|
|
1459 build_string ("JISX0201.1976 Japanese Roman"),
|
|
1460 build_string ("jisx0201.1976"));
|
|
1461 staticpro (&Vcharset_cyrillic_iso8859_5);
|
|
1462 Vcharset_cyrillic_iso8859_5 =
|
|
1463 make_charset (LEADING_BYTE_CYRILLIC_ISO8859_5, Qcyrillic_iso8859_5, 2,
|
|
1464 CHARSET_TYPE_96, 1, 1, 'L',
|
|
1465 CHARSET_LEFT_TO_RIGHT,
|
|
1466 build_string ("ISO8859-5"),
|
|
1467 build_string ("ISO8859-5 (Cyrillic)"),
|
|
1468 build_string ("ISO8859-5 (Cyrillic)"),
|
|
1469 build_string ("iso8859-5"));
|
|
1470 staticpro (&Vcharset_latin_iso8859_9);
|
|
1471 Vcharset_latin_iso8859_9 =
|
|
1472 make_charset (LEADING_BYTE_LATIN_ISO8859_9, Qlatin_iso8859_9, 2,
|
|
1473 CHARSET_TYPE_96, 1, 1, 'M',
|
|
1474 CHARSET_LEFT_TO_RIGHT,
|
|
1475 build_string ("Latin-5"),
|
|
1476 build_string ("ISO8859-9 (Latin-5)"),
|
|
1477 build_string ("ISO8859-9 (Latin-5)"),
|
|
1478 build_string ("iso8859-9"));
|
|
1479 staticpro (&Vcharset_japanese_jisx0208_1978);
|
|
1480 Vcharset_japanese_jisx0208_1978 =
|
|
1481 make_charset (LEADING_BYTE_JAPANESE_JISX0208_1978, Qjapanese_jisx0208_1978, 3,
|
|
1482 CHARSET_TYPE_94X94, 2, 0, '@',
|
|
1483 CHARSET_LEFT_TO_RIGHT,
|
|
1484 build_string ("JISX0208.1978"),
|
|
1485 build_string ("JISX0208.1978 (Japanese)"),
|
|
1486 build_string
|
|
1487 ("JISX0208.1978 Japanese Kanji (so called \"old JIS\")"),
|
|
1488 build_string ("\\(jisx0208\\|jisc6226\\)\\.1978"));
|
|
1489 staticpro (&Vcharset_chinese_gb2312);
|
|
1490 Vcharset_chinese_gb2312 =
|
|
1491 make_charset (LEADING_BYTE_CHINESE_GB2312, Qchinese_gb2312, 3,
|
|
1492 CHARSET_TYPE_94X94, 2, 0, 'A',
|
|
1493 CHARSET_LEFT_TO_RIGHT,
|
|
1494 build_string ("GB2312"),
|
|
1495 build_string ("GB2312)"),
|
|
1496 build_string ("GB2312 Chinese simplified"),
|
|
1497 build_string ("gb2312"));
|
|
1498 staticpro (&Vcharset_japanese_jisx0208);
|
|
1499 Vcharset_japanese_jisx0208 =
|
|
1500 make_charset (LEADING_BYTE_JAPANESE_JISX0208, Qjapanese_jisx0208, 3,
|
|
1501 CHARSET_TYPE_94X94, 2, 0, 'B',
|
|
1502 CHARSET_LEFT_TO_RIGHT,
|
|
1503 build_string ("JISX0208"),
|
|
1504 build_string ("JISX0208.1983/1990 (Japanese)"),
|
|
1505 build_string ("JISX0208.1983/1990 Japanese Kanji"),
|
|
1506 build_string ("jisx0208.19\\(83\\|90\\)"));
|
|
1507 staticpro (&Vcharset_korean_ksc5601);
|
|
1508 Vcharset_korean_ksc5601 =
|
|
1509 make_charset (LEADING_BYTE_KOREAN_KSC5601, Qkorean_ksc5601, 3,
|
|
1510 CHARSET_TYPE_94X94, 2, 0, 'C',
|
|
1511 CHARSET_LEFT_TO_RIGHT,
|
|
1512 build_string ("KSC5601"),
|
|
1513 build_string ("KSC5601 (Korean"),
|
|
1514 build_string ("KSC5601 Korean Hangul and Hanja"),
|
|
1515 build_string ("ksc5601"));
|
|
1516 staticpro (&Vcharset_japanese_jisx0212);
|
|
1517 Vcharset_japanese_jisx0212 =
|
|
1518 make_charset (LEADING_BYTE_JAPANESE_JISX0212, Qjapanese_jisx0212, 3,
|
|
1519 CHARSET_TYPE_94X94, 2, 0, 'D',
|
|
1520 CHARSET_LEFT_TO_RIGHT,
|
|
1521 build_string ("JISX0212"),
|
|
1522 build_string ("JISX0212 (Japanese)"),
|
|
1523 build_string ("JISX0212 Japanese Supplement"),
|
|
1524 build_string ("jisx0212"));
|
|
1525
|
|
1526 #define CHINESE_CNS_PLANE_RE(n) "cns11643[.-]\\(.*[.-]\\)?" n "$"
|
|
1527 staticpro (&Vcharset_chinese_cns11643_1);
|
|
1528 Vcharset_chinese_cns11643_1 =
|
|
1529 make_charset (LEADING_BYTE_CHINESE_CNS11643_1, Qchinese_cns11643_1, 3,
|
|
1530 CHARSET_TYPE_94X94, 2, 0, 'G',
|
|
1531 CHARSET_LEFT_TO_RIGHT,
|
|
1532 build_string ("CNS11643-1"),
|
|
1533 build_string ("CNS11643-1 (Chinese traditional)"),
|
|
1534 build_string
|
|
1535 ("CNS 11643 Plane 1 Chinese traditional"),
|
|
1536 build_string (CHINESE_CNS_PLANE_RE("1")));
|
|
1537 staticpro (&Vcharset_chinese_cns11643_2);
|
|
1538 Vcharset_chinese_cns11643_2 =
|
|
1539 make_charset (LEADING_BYTE_CHINESE_CNS11643_2, Qchinese_cns11643_2, 3,
|
|
1540 CHARSET_TYPE_94X94, 2, 0, 'H',
|
|
1541 CHARSET_LEFT_TO_RIGHT,
|
|
1542 build_string ("CNS11643-2"),
|
|
1543 build_string ("CNS11643-2 (Chinese traditional)"),
|
|
1544 build_string
|
|
1545 ("CNS 11643 Plane 2 Chinese traditional"),
|
|
1546 build_string (CHINESE_CNS_PLANE_RE("2")));
|
|
1547 staticpro (&Vcharset_chinese_big5_1);
|
|
1548 Vcharset_chinese_big5_1 =
|
|
1549 make_charset (LEADING_BYTE_CHINESE_BIG5_1, Qchinese_big5_1, 3,
|
|
1550 CHARSET_TYPE_94X94, 2, 0, '0',
|
|
1551 CHARSET_LEFT_TO_RIGHT,
|
|
1552 build_string ("Big5"),
|
|
1553 build_string ("Big5 (Level-1)"),
|
|
1554 build_string
|
|
1555 ("Big5 Level-1 Chinese traditional"),
|
|
1556 build_string ("big5"));
|
|
1557 staticpro (&Vcharset_chinese_big5_2);
|
|
1558 Vcharset_chinese_big5_2 =
|
|
1559 make_charset (LEADING_BYTE_CHINESE_BIG5_2, Qchinese_big5_2, 3,
|
|
1560 CHARSET_TYPE_94X94, 2, 0, '1',
|
|
1561 CHARSET_LEFT_TO_RIGHT,
|
|
1562 build_string ("Big5"),
|
|
1563 build_string ("Big5 (Level-2)"),
|
|
1564 build_string
|
|
1565 ("Big5 Level-2 Chinese traditional"),
|
|
1566 build_string ("big5"));
|
|
1567
|
|
1568
|
|
1569 #ifdef ENABLE_COMPOSITE_CHARS
|
|
1570 /* #### For simplicity, we put composite chars into a 96x96 charset.
|
|
1571 This is going to lead to problems because you can run out of
|
|
1572 room, esp. as we don't yet recycle numbers. */
|
|
1573 staticpro (&Vcharset_composite);
|
|
1574 Vcharset_composite =
|
|
1575 make_charset (LEADING_BYTE_COMPOSITE, Qcomposite, 3,
|
|
1576 CHARSET_TYPE_96X96, 2, 0, 0,
|
|
1577 CHARSET_LEFT_TO_RIGHT,
|
|
1578 build_string ("Composite"),
|
|
1579 build_string ("Composite characters"),
|
|
1580 build_string ("Composite characters"),
|
|
1581 build_string (""));
|
|
1582
|
|
1583 /* #### not dumped properly */
|
|
1584 composite_char_row_next = 32;
|
|
1585 composite_char_col_next = 32;
|
|
1586
|
|
1587 Vcomposite_char_string2char_hash_table =
|
|
1588 make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
|
|
1589 Vcomposite_char_char2string_hash_table =
|
|
1590 make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
|
|
1591 staticpro (&Vcomposite_char_string2char_hash_table);
|
|
1592 staticpro (&Vcomposite_char_char2string_hash_table);
|
|
1593 #endif /* ENABLE_COMPOSITE_CHARS */
|
|
1594
|
|
1595 }
|