(MAKE_CHAR): Check the result for range-represented charset.
[chise/xemacs-chise.git] / src / mule-charset.c
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 #ifdef UTF2000
61 Lisp_Object Vcharset_ucs_bmp;
62 Lisp_Object Vcharset_latin_viscii_lower;
63 Lisp_Object Vcharset_latin_viscii_upper;
64 Lisp_Object Vcharset_hiragana_jisx0208;
65 Lisp_Object Vcharset_katakana_jisx0208;
66 #endif
67 Lisp_Object Vcharset_chinese_big5_1;
68 Lisp_Object Vcharset_chinese_big5_2;
69
70 #ifdef ENABLE_COMPOSITE_CHARS
71 Lisp_Object Vcharset_composite;
72
73 /* Hash tables for composite chars.  One maps string representing
74    composed chars to their equivalent chars; one goes the
75    other way. */
76 Lisp_Object Vcomposite_char_char2string_hash_table;
77 Lisp_Object Vcomposite_char_string2char_hash_table;
78
79 static int composite_char_row_next;
80 static int composite_char_col_next;
81
82 #endif /* ENABLE_COMPOSITE_CHARS */
83
84 /* Table of charsets indexed by leading byte. */
85 Lisp_Object charset_by_leading_byte[NUM_LEADING_BYTES];
86
87 /* Table of charsets indexed by type/final-byte/direction. */
88 #ifdef UTF2000
89 Lisp_Object charset_by_attributes[4][128];
90 #else
91 Lisp_Object charset_by_attributes[4][128][2];
92 #endif
93
94 #ifndef UTF2000
95 /* Table of number of bytes in the string representation of a character
96    indexed by the first byte of that representation.
97
98    rep_bytes_by_first_byte(c) is more efficient than the equivalent
99    canonical computation:
100
101    (BYTE_ASCII_P (c) ? 1 : XCHARSET_REP_BYTES (CHARSET_BY_LEADING_BYTE (c))) */
102
103 Bytecount rep_bytes_by_first_byte[0xA0] =
104 { /* 0x00 - 0x7f are for straight ASCII */
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   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
108   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
109   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
110   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
111   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
112   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
113   /* 0x80 - 0x8f are for Dimension-1 official charsets */
114 #ifdef CHAR_IS_UCS4
115   2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3,
116 #else
117   2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
118 #endif
119   /* 0x90 - 0x9d are for Dimension-2 official charsets */
120   /* 0x9e is for Dimension-1 private charsets */
121   /* 0x9f is for Dimension-2 private charsets */
122   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
123 };
124 #endif
125
126 #ifdef UTF2000
127 Emchar_to_byte_table*
128 make_byte_from_character_table ()
129 {
130   Emchar_to_byte_table* table
131     = (Emchar_to_byte_table*) xmalloc (sizeof (Emchar_to_byte_table));
132
133   table->base = NULL;
134   return table;
135 }
136
137 void
138 put_byte_from_character_table (Emchar ch, unsigned char val,
139                                Emchar_to_byte_table* table)
140 {
141   if (table->base == NULL)
142     {
143       table->base = xmalloc (128);
144       table->offset = ch - (ch % 128);
145       table->size = 128;
146       table->base[ch - table->offset] = val;
147     }
148   else
149     {
150       int i = ch - table->offset;
151
152       if (i < 0)
153         {
154           size_t new_size = table->size - i;
155           size_t j;
156
157           new_size += 128 - (new_size % 128);
158           table->base = xrealloc (table->base, new_size);
159           memmove (table->base + (new_size - table->size), table->base,
160                    table->size);
161           for (j = 0; j < (new_size - table->size); j++)
162             table->base[j] = 0;
163           table->offset -= (new_size - table->size);
164           table->base[ch - table->offset] = val;
165           table->size = new_size;
166         }
167       else if (i >= table->size)
168         {
169           size_t new_size = i + 1;
170           size_t j;
171
172           new_size += 128 - (new_size % 128);
173           table->base = xrealloc (table->base, new_size);
174           for (j = table->size; j < new_size; j++)
175             table->base[j] = 0;
176           table->base[i] = val;
177           table->size = new_size;
178         }
179       else
180         {
181           table->base[i] = val;
182         }
183     }
184 }
185
186 unsigned char
187 get_byte_from_character_table (Emchar ch, Emchar_to_byte_table* table)
188 {
189   size_t i = ch - table->offset;
190   if (i < table->size)
191     return table->base[i];
192   else
193     return 0;
194 }
195
196 Lisp_Object latin_jisx0201_to_ucs;
197 Lisp_Object latin_iso8859_2_to_ucs;
198 Lisp_Object latin_iso8859_3_to_ucs;
199 Lisp_Object latin_iso8859_4_to_ucs;
200 Lisp_Object latin_iso8859_9_to_ucs;
201 Lisp_Object latin_viscii_lower_to_ucs;
202 Lisp_Object latin_viscii_upper_to_ucs;
203
204 #if 0
205 Emchar latin_tcvn5712_to_ucs[96] =
206 {
207   0x00A0 /* 0xA0  NO-BREAK SPACE */,
208   0x0102 /* 0xA1  LATIN CAPITAL LETTER A WITH BREVE */,
209   0x00C2 /* 0xA2  LATIN CAPITAL LETTER A WITH CIRCUMFLEX */,
210   0x00CA /* 0xA3  LATIN CAPITAL LETTER E WITH CIRCUMFLEX */,
211   0x00D4 /* 0xA4  LATIN CAPITAL LETTER O WITH CIRCUMFLEX */,
212   0x01A0 /* 0xA5  LATIN CAPITAL LETTER O WITH HORN */,
213   0x01AF /* 0xA6  LATIN CAPITAL LETTER U WITH HORN */,
214   0x0110 /* 0xA7  LATIN CAPITAL LETTER D WITH STROKE */,
215   0x0103 /* 0xA8  LATIN SMALL LETTER A WITH BREVE */,
216   0x00E2 /* 0xA9  LATIN SMALL LETTER A WITH CIRCUMFLEX */,
217   0x00EA /* 0xAA  LATIN SMALL LETTER E WITH CIRCUMFLEX */,
218   0x00F4 /* 0xAB  LATIN SMALL LETTER O WITH CIRCUMFLEX */,
219   0x01A1 /* 0xAC  LATIN SMALL LETTER O WITH HORN */,
220   0x01B0 /* 0xAD  LATIN SMALL LETTER U WITH HORN */,
221   0x0111 /* 0xAE  LATIN SMALL LETTER D WITH STROKE */,
222   0x1EB0 /* 0xAF  LATIN CAPITAL LETTER A WITH BREVE AND GRAVE */,
223   0x0300 /* 0xB0  COMBINING GRAVE ACCENT */,
224   0x0309 /* 0xB1  COMBINING HOOK ABOVE */,
225   0x0303 /* 0xB2  COMBINING TILDE */,
226   0x0301 /* 0xB3  COMBINING ACUTE ACCENT */,
227   0x0323 /* 0xB4  COMBINING DOT BELOW */,
228   0x00E0 /* 0xB5  LATIN SMALL LETTER A WITH GRAVE */,
229   0x1EA3 /* 0xB6  LATIN SMALL LETTER A WITH HOOK ABOVE */,
230   0x00E3 /* 0xB7  LATIN SMALL LETTER A WITH TILDE */,
231   0x00E1 /* 0xB8  LATIN SMALL LETTER A WITH ACUTE */,
232   0x1EA1 /* 0xB9  LATIN SMALL LETTER A WITH DOT BELOW */,
233   0x1EB2 /* 0xBA  LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE */,
234   0x1EB1 /* 0xBB  LATIN SMALL LETTER A WITH BREVE AND GRAVE */,
235   0x1EB3 /* 0xBC  LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE */,
236   0x1EB5 /* 0xBD  LATIN SMALL LETTER A WITH BREVE AND TILDE */,
237   0x1EAF /* 0xBE  LATIN SMALL LETTER A WITH BREVE AND ACUTE */,
238   0x1EB4 /* 0xBF  LATIN CAPITAL LETTER A WITH BREVE AND TILDE */,
239   0x1EAE /* 0xC0  LATIN CAPITAL LETTER A WITH BREVE AND ACUTE */,
240   0x1EA6 /* 0xC1  LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE */,
241   0x1EA8 /* 0xC2  LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */,
242   0x1EAA /* 0xC3  LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE */,
243   0x1EA4 /* 0xC4  LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE */,
244   0x1EC0 /* 0xC5  LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE */,
245   0x1EB7 /* 0xC6  LATIN SMALL LETTER A WITH BREVE AND DOT BELOW */,
246   0x1EA7 /* 0xC7  LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE */,
247   0x1EA9 /* 0xC8  LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */,
248   0x1EAB /* 0xC9  LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE */,
249   0x1EA5 /* 0xCA  LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE */,
250   0x1EAD /* 0xCB  LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW */,
251   0x00E8 /* 0xCC  LATIN SMALL LETTER E WITH GRAVE */,
252   0x1EC2 /* 0xCD  LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */,
253   0x1EBB /* 0xCE  LATIN SMALL LETTER E WITH HOOK ABOVE */,
254   0x1EBD /* 0xCF  LATIN SMALL LETTER E WITH TILDE */,
255   0x00E9 /* 0xD0  LATIN SMALL LETTER E WITH ACUTE */,
256   0x1EB9 /* 0xD1  LATIN SMALL LETTER E WITH DOT BELOW */,
257   0x1EC1 /* 0xD2  LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE */,
258   0x1EC3 /* 0xD3  LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */,
259   0x1EC5 /* 0xD4  LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE */,
260   0x1EBF /* 0xD5  LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE */,
261   0x1EC7 /* 0xD6  LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW */,
262   0x00EC /* 0xD7  LATIN SMALL LETTER I WITH GRAVE */,
263   0x1EC9 /* 0xD8  LATIN SMALL LETTER I WITH HOOK ABOVE */,
264   0x1EC4 /* 0xD9  LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE */,
265   0x1EBE /* 0xDA  LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE */,
266   0x1ED2 /* 0xDB  LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE */,
267   0x0129 /* 0xDC  LATIN SMALL LETTER I WITH TILDE */,
268   0x00ED /* 0xDD  LATIN SMALL LETTER I WITH ACUTE */,
269   0x1ECB /* 0xDE  LATIN SMALL LETTER I WITH DOT BELOW */,
270   0x00F2 /* 0xDF  LATIN SMALL LETTER O WITH GRAVE */,
271   0x1ED4 /* 0xE0  LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */,
272   0x1ECF /* 0xE1  LATIN SMALL LETTER O WITH HOOK ABOVE */,
273   0x00F5 /* 0xE2  LATIN SMALL LETTER O WITH TILDE */,
274   0x00F3 /* 0xE3  LATIN SMALL LETTER O WITH ACUTE */,
275   0x1ECD /* 0xE4  LATIN SMALL LETTER O WITH DOT BELOW */,
276   0x1ED3 /* 0xE5  LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE */,
277   0x1ED5 /* 0xE6  LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */,
278   0x1ED7 /* 0xE7  LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE */,
279   0x1ED1 /* 0xE8  LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE */,
280   0x1ED9 /* 0xE9  LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW */,
281   0x1EDD /* 0xEA  LATIN SMALL LETTER O WITH HORN AND GRAVE */,
282   0x1EDF /* 0xEB  LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE */,
283   0x1EE1 /* 0xEC  LATIN SMALL LETTER O WITH HORN AND TILDE */,
284   0x1EDB /* 0xED  LATIN SMALL LETTER O WITH HORN AND ACUTE */,
285   0x1EE3 /* 0xEE  LATIN SMALL LETTER O WITH HORN AND DOT BELOW */,
286   0x00F9 /* 0xEF  LATIN SMALL LETTER U WITH GRAVE */,
287   0x1ED6 /* 0xF0  LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE */,
288   0x1EE7 /* 0xF1  LATIN SMALL LETTER U WITH HOOK ABOVE */,
289   0x0169 /* 0xF2  LATIN SMALL LETTER U WITH TILDE */,
290   0x00FA /* 0xF3  LATIN SMALL LETTER U WITH ACUTE */,
291   0x1EE5 /* 0xF4  LATIN SMALL LETTER U WITH DOT BELOW */,
292   0x1EEB /* 0xF5  LATIN SMALL LETTER U WITH HORN AND GRAVE */,
293   0x1EED /* 0xF6  LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE */,
294   0x1EEF /* 0xF7  LATIN SMALL LETTER U WITH HORN AND TILDE */,
295   0x1EE9 /* 0xF8  LATIN SMALL LETTER U WITH HORN AND ACUTE */,
296   0x1EF1 /* 0xF9  LATIN SMALL LETTER U WITH HORN AND DOT BELOW */,
297   0x1EF3 /* 0xFA  LATIN SMALL LETTER Y WITH GRAVE */,
298   0x1EF7 /* 0xFB  LATIN SMALL LETTER Y WITH HOOK ABOVE */,
299   0x1EF9 /* 0xFC  LATIN SMALL LETTER Y WITH TILDE */,
300   0x00FD /* 0xFD  LATIN SMALL LETTER Y WITH ACUTE */,
301   0x1EF5 /* 0xFE  LATIN SMALL LETTER Y WITH DOT BELOW */,
302   0x1ED0 /* 0xFF  LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE */
303 };
304 #endif
305
306 Lisp_Object Vutf_2000_version;
307 #endif
308
309 #ifndef UTF2000
310 int leading_code_private_11;
311 #endif
312
313 Lisp_Object Qcharsetp;
314
315 /* Qdoc_string, Qdimension, Qchars defined in general.c */
316 Lisp_Object Qregistry, Qfinal, Qgraphic;
317 Lisp_Object Qdirection;
318 Lisp_Object Qreverse_direction_charset;
319 Lisp_Object Qleading_byte;
320 Lisp_Object Qshort_name, Qlong_name;
321
322 Lisp_Object Qascii,
323   Qcontrol_1,
324   Qlatin_iso8859_1,
325   Qlatin_iso8859_2,
326   Qlatin_iso8859_3,
327   Qlatin_iso8859_4,
328   Qthai_tis620,
329   Qgreek_iso8859_7,
330   Qarabic_iso8859_6,
331   Qhebrew_iso8859_8,
332   Qkatakana_jisx0201,
333   Qlatin_jisx0201,
334   Qcyrillic_iso8859_5,
335   Qlatin_iso8859_9,
336   Qjapanese_jisx0208_1978,
337   Qchinese_gb2312,
338   Qjapanese_jisx0208,
339   Qkorean_ksc5601,
340   Qjapanese_jisx0212,
341   Qchinese_cns11643_1,
342   Qchinese_cns11643_2,
343 #ifdef UTF2000
344   Qucs_bmp,
345   Qlatin_viscii_lower,
346   Qlatin_viscii_upper,
347   Qhiragana_jisx0208,
348   Qkatakana_jisx0208,
349 #endif
350   Qchinese_big5_1,
351   Qchinese_big5_2,
352   Qcomposite;
353
354 Lisp_Object Ql2r, Qr2l;
355
356 Lisp_Object Vcharset_hash_table;
357
358 static Charset_ID next_allocated_1_byte_leading_byte;
359 static Charset_ID next_allocated_2_byte_leading_byte;
360
361 /* Composite characters are characters constructed by overstriking two
362    or more regular characters.
363
364    1) The old Mule implementation involves storing composite characters
365       in a buffer as a tag followed by all of the actual characters
366       used to make up the composite character.  I think this is a bad
367       idea; it greatly complicates code that wants to handle strings
368       one character at a time because it has to deal with the possibility
369       of great big ungainly characters.  It's much more reasonable to
370       simply store an index into a table of composite characters.
371
372    2) The current implementation only allows for 16,384 separate
373       composite characters over the lifetime of the XEmacs process.
374       This could become a potential problem if the user
375       edited lots of different files that use composite characters.
376       Due to FSF bogosity, increasing the number of allowable
377       composite characters under Mule would decrease the number
378       of possible faces that can exist.  Mule already has shrunk
379       this to 2048, and further shrinkage would become uncomfortable.
380       No such problems exist in XEmacs.
381
382       Composite characters could be represented as 0x80 C1 C2 C3,
383       where each C[1-3] is in the range 0xA0 - 0xFF.  This allows
384       for slightly under 2^20 (one million) composite characters
385       over the XEmacs process lifetime, and you only need to
386       increase the size of a Mule character from 19 to 21 bits.
387       Or you could use 0x80 C1 C2 C3 C4, allowing for about
388       85 million (slightly over 2^26) composite characters. */
389
390 \f
391 /************************************************************************/
392 /*                       Basic Emchar functions                         */
393 /************************************************************************/
394
395 /* Convert a non-ASCII Mule character C into a one-character Mule-encoded
396    string in STR.  Returns the number of bytes stored.
397    Do not call this directly.  Use the macro set_charptr_emchar() instead.
398  */
399
400 Bytecount
401 non_ascii_set_charptr_emchar (Bufbyte *str, Emchar c)
402 {
403   Bufbyte *p;
404 #ifndef UTF2000
405   Charset_ID lb;
406   int c1, c2;
407   Lisp_Object charset;
408 #endif
409
410   p = str;
411 #ifdef UTF2000
412   if ( c <= 0x7f )
413     {
414       *p++ = c;
415     }
416   else if ( c <= 0x7ff )
417     {
418       *p++ = (c >> 6) | 0xc0;
419       *p++ = (c & 0x3f) | 0x80;
420     }
421   else if ( c <= 0xffff )
422     {
423       *p++ =  (c >> 12) | 0xe0;
424       *p++ = ((c >>  6) & 0x3f) | 0x80;
425       *p++ =  (c        & 0x3f) | 0x80;
426     }
427   else if ( c <= 0x1fffff )
428     {
429       *p++ =  (c >> 18) | 0xf0;
430       *p++ = ((c >> 12) & 0x3f) | 0x80;
431       *p++ = ((c >>  6) & 0x3f) | 0x80;
432       *p++ =  (c        & 0x3f) | 0x80;
433     }
434   else if ( c <= 0x3ffffff )
435     {
436       *p++ =  (c >> 24) | 0xf8;
437       *p++ = ((c >> 18) & 0x3f) | 0x80;
438       *p++ = ((c >> 12) & 0x3f) | 0x80;
439       *p++ = ((c >>  6) & 0x3f) | 0x80;
440       *p++ =  (c        & 0x3f) | 0x80;
441     }
442   else
443     {
444       *p++ =  (c >> 30) | 0xfc;
445       *p++ = ((c >> 24) & 0x3f) | 0x80;
446       *p++ = ((c >> 18) & 0x3f) | 0x80;
447       *p++ = ((c >> 12) & 0x3f) | 0x80;
448       *p++ = ((c >>  6) & 0x3f) | 0x80;
449       *p++ =  (c        & 0x3f) | 0x80;
450     }
451 #else
452   BREAKUP_CHAR (c, charset, c1, c2);
453   lb = CHAR_LEADING_BYTE (c);
454   if (LEADING_BYTE_PRIVATE_P (lb))
455     *p++ = PRIVATE_LEADING_BYTE_PREFIX (lb);
456   *p++ = lb;
457   if (EQ (charset, Vcharset_control_1))
458     c1 += 0x20;
459   *p++ = c1 | 0x80;
460   if (c2)
461     *p++ = c2 | 0x80;
462 #endif
463   return (p - str);
464 }
465
466 /* Return the first character from a Mule-encoded string in STR,
467    assuming it's non-ASCII.  Do not call this directly.
468    Use the macro charptr_emchar() instead. */
469
470 Emchar
471 non_ascii_charptr_emchar (CONST Bufbyte *str)
472 {
473 #ifdef UTF2000
474   Bufbyte b;
475   Emchar ch;
476   int len;
477
478   b = *str++;
479   if ( b >= 0xfc )
480     {
481       ch = (b & 0x01);
482       len = 5;
483     }
484   else if ( b >= 0xf8 )
485     {
486       ch = b & 0x03;
487       len = 4;
488     }
489   else if ( b >= 0xf0 )
490     {
491       ch = b & 0x07;
492       len = 3;
493     }
494   else if ( b >= 0xe0 )
495     {
496       ch = b & 0x0f;
497       len = 2;
498     }
499   else if ( b >= 0xc0 )
500     {
501       ch = b & 0x1f;
502       len = 1;
503     }
504   else
505     {
506       ch = b;
507       len = 0;
508     }
509   for( ; len > 0; len-- )
510     {
511       b = *str++;
512       ch = ( ch << 6 ) | ( b & 0x3f );
513     }
514   return ch;
515 #else
516   Bufbyte i0 = *str, i1, i2 = 0;
517   Lisp_Object charset;
518
519   if (i0 == LEADING_BYTE_CONTROL_1)
520     return (Emchar) (*++str - 0x20);
521
522   if (LEADING_BYTE_PREFIX_P (i0))
523     i0 = *++str;
524
525   i1 = *++str & 0x7F;
526
527   charset = CHARSET_BY_LEADING_BYTE (i0);
528   if (XCHARSET_DIMENSION (charset) == 2)
529     i2 = *++str & 0x7F;
530
531   return MAKE_CHAR (charset, i1, i2);
532 #endif
533 }
534
535 /* Return whether CH is a valid Emchar, assuming it's non-ASCII.
536    Do not call this directly.  Use the macro valid_char_p() instead. */
537
538 #ifndef UTF2000
539 int
540 non_ascii_valid_char_p (Emchar ch)
541 {
542   int f1, f2, f3;
543
544   /* Must have only lowest 19 bits set */
545   if (ch & ~0x7FFFF)
546     return 0;
547
548   f1 = CHAR_FIELD1 (ch);
549   f2 = CHAR_FIELD2 (ch);
550   f3 = CHAR_FIELD3 (ch);
551
552   if (f1 == 0)
553     {
554       Lisp_Object charset;
555
556       if (f2 < MIN_CHAR_FIELD2_OFFICIAL ||
557           (f2 > MAX_CHAR_FIELD2_OFFICIAL && f2 < MIN_CHAR_FIELD2_PRIVATE) ||
558            f2 > MAX_CHAR_FIELD2_PRIVATE)
559         return 0;
560       if (f3 < 0x20)
561         return 0;
562
563       if (f3 != 0x20 && f3 != 0x7F)
564         return 1;
565
566       /*
567          NOTE: This takes advantage of the fact that
568          FIELD2_TO_OFFICIAL_LEADING_BYTE and
569          FIELD2_TO_PRIVATE_LEADING_BYTE are the same.
570          */
571       charset = CHARSET_BY_LEADING_BYTE (f2 + FIELD2_TO_OFFICIAL_LEADING_BYTE);
572       return (XCHARSET_CHARS (charset) == 96);
573     }
574   else
575     {
576       Lisp_Object charset;
577
578       if (f1 < MIN_CHAR_FIELD1_OFFICIAL ||
579           (f1 > MAX_CHAR_FIELD1_OFFICIAL && f1 < MIN_CHAR_FIELD1_PRIVATE) ||
580           f1 > MAX_CHAR_FIELD1_PRIVATE)
581         return 0;
582       if (f2 < 0x20 || f3 < 0x20)
583         return 0;
584
585 #ifdef ENABLE_COMPOSITE_CHARS
586       if (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE == LEADING_BYTE_COMPOSITE)
587         {
588           if (UNBOUNDP (Fgethash (make_int (ch),
589                                   Vcomposite_char_char2string_hash_table,
590                                   Qunbound)))
591             return 0;
592           return 1;
593         }
594 #endif /* ENABLE_COMPOSITE_CHARS */
595
596       if (f2 != 0x20 && f2 != 0x7F && f3 != 0x20 && f3 != 0x7F)
597         return 1;
598
599       if (f1 <= MAX_CHAR_FIELD1_OFFICIAL)
600         charset =
601           CHARSET_BY_LEADING_BYTE (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE);
602       else
603         charset =
604           CHARSET_BY_LEADING_BYTE (f1 + FIELD1_TO_PRIVATE_LEADING_BYTE);
605
606       return (XCHARSET_CHARS (charset) == 96);
607     }
608 }
609 #endif
610
611 \f
612 /************************************************************************/
613 /*                       Basic string functions                         */
614 /************************************************************************/
615
616 /* Copy the character pointed to by PTR into STR, assuming it's
617    non-ASCII.  Do not call this directly.  Use the macro
618    charptr_copy_char() instead. */
619
620 Bytecount
621 non_ascii_charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *str)
622 {
623   Bufbyte *strptr = str;
624   *strptr = *ptr++;
625   switch (REP_BYTES_BY_FIRST_BYTE (*strptr))
626     {
627       /* Notice fallthrough. */
628 #ifdef UTF2000
629     case 6: *++strptr = *ptr++;
630     case 5: *++strptr = *ptr++;
631 #endif
632     case 4: *++strptr = *ptr++;
633     case 3: *++strptr = *ptr++;
634     case 2: *++strptr = *ptr;
635       break;
636     default:
637       abort ();
638     }
639   return strptr + 1 - str;
640 }
641
642 \f
643 /************************************************************************/
644 /*                        streams of Emchars                            */
645 /************************************************************************/
646
647 /* Treat a stream as a stream of Emchar's rather than a stream of bytes.
648    The functions below are not meant to be called directly; use
649    the macros in insdel.h. */
650
651 Emchar
652 Lstream_get_emchar_1 (Lstream *stream, int ch)
653 {
654   Bufbyte str[MAX_EMCHAR_LEN];
655   Bufbyte *strptr = str;
656
657   str[0] = (Bufbyte) ch;
658   switch (REP_BYTES_BY_FIRST_BYTE (ch))
659     {
660       /* Notice fallthrough. */
661 #ifdef UTF2000
662     case 6:
663       ch = Lstream_getc (stream);
664       assert (ch >= 0);
665       *++strptr = (Bufbyte) ch;
666     case 5:
667       ch = Lstream_getc (stream);
668       assert (ch >= 0);
669       *++strptr = (Bufbyte) ch;
670 #endif
671     case 4:
672       ch = Lstream_getc (stream);
673       assert (ch >= 0);
674       *++strptr = (Bufbyte) ch;
675     case 3:
676       ch = Lstream_getc (stream);
677       assert (ch >= 0);
678       *++strptr = (Bufbyte) ch;
679     case 2:
680       ch = Lstream_getc (stream);
681       assert (ch >= 0);
682       *++strptr = (Bufbyte) ch;
683       break;
684     default:
685       abort ();
686     }
687   return charptr_emchar (str);
688 }
689
690 int
691 Lstream_fput_emchar (Lstream *stream, Emchar ch)
692 {
693   Bufbyte str[MAX_EMCHAR_LEN];
694   Bytecount len = set_charptr_emchar (str, ch);
695   return Lstream_write (stream, str, len);
696 }
697
698 void
699 Lstream_funget_emchar (Lstream *stream, Emchar ch)
700 {
701   Bufbyte str[MAX_EMCHAR_LEN];
702   Bytecount len = set_charptr_emchar (str, ch);
703   Lstream_unread (stream, str, len);
704 }
705
706 \f
707 /************************************************************************/
708 /*                            charset object                            */
709 /************************************************************************/
710
711 static Lisp_Object
712 mark_charset (Lisp_Object obj, void (*markobj) (Lisp_Object))
713 {
714   struct Lisp_Charset *cs = XCHARSET (obj);
715
716   markobj (cs->short_name);
717   markobj (cs->long_name);
718   markobj (cs->doc_string);
719   markobj (cs->registry);
720   markobj (cs->ccl_program);
721   return cs->name;
722 }
723
724 static void
725 print_charset (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
726 {
727   struct Lisp_Charset *cs = XCHARSET (obj);
728   char buf[200];
729
730   if (print_readably)
731     error ("printing unreadable object #<charset %s 0x%x>",
732            string_data (XSYMBOL (CHARSET_NAME (cs))->name),
733            cs->header.uid);
734
735   write_c_string ("#<charset ", printcharfun);
736   print_internal (CHARSET_NAME (cs), printcharfun, 0);
737   write_c_string (" ", printcharfun);
738   print_internal (CHARSET_SHORT_NAME (cs), printcharfun, 1);
739   write_c_string (" ", printcharfun);
740   print_internal (CHARSET_LONG_NAME (cs), printcharfun, 1);
741   write_c_string (" ", printcharfun);
742   print_internal (CHARSET_DOC_STRING (cs), printcharfun, 1);
743   sprintf (buf, " %s %s cols=%d g%d final='%c' reg=",
744            CHARSET_TYPE (cs) == CHARSET_TYPE_94    ? "94" :
745            CHARSET_TYPE (cs) == CHARSET_TYPE_96    ? "96" :
746            CHARSET_TYPE (cs) == CHARSET_TYPE_94X94 ? "94x94" :
747            "96x96",
748            CHARSET_DIRECTION (cs) == CHARSET_LEFT_TO_RIGHT ? "l2r" : "r2l",
749            CHARSET_COLUMNS (cs),
750            CHARSET_GRAPHIC (cs),
751            CHARSET_FINAL (cs));
752   write_c_string (buf, printcharfun);
753   print_internal (CHARSET_REGISTRY (cs), printcharfun, 0);
754   sprintf (buf, " 0x%x>", cs->header.uid);
755   write_c_string (buf, printcharfun);
756 }
757
758 static const struct lrecord_description charset_description[] = {
759   { XD_LISP_OBJECT, offsetof(struct Lisp_Charset, name), 7 },
760   { XD_END }
761 };
762
763 DEFINE_LRECORD_IMPLEMENTATION ("charset", charset,
764                                mark_charset, print_charset, 0, 0, 0,
765                                charset_description,
766                                struct Lisp_Charset);
767 /* Make a new charset. */
768
769 static Lisp_Object
770 make_charset (Charset_ID id, Lisp_Object name,
771               unsigned char type, unsigned char columns, unsigned char graphic,
772               Bufbyte final, unsigned char direction, Lisp_Object short_name,
773               Lisp_Object long_name, Lisp_Object doc,
774               Lisp_Object reg,
775               Lisp_Object decoding_table,
776               Emchar ucs_min, Emchar ucs_max,
777               Emchar code_offset, unsigned char byte_offset)
778 {
779   Lisp_Object obj;
780   struct Lisp_Charset *cs =
781     alloc_lcrecord_type (struct Lisp_Charset, &lrecord_charset);
782   XSETCHARSET (obj, cs);
783
784   CHARSET_ID            (cs) = id;
785   CHARSET_NAME          (cs) = name;
786   CHARSET_SHORT_NAME    (cs) = short_name;
787   CHARSET_LONG_NAME     (cs) = long_name;
788   CHARSET_DIRECTION     (cs) = direction;
789   CHARSET_TYPE          (cs) = type;
790   CHARSET_COLUMNS       (cs) = columns;
791   CHARSET_GRAPHIC       (cs) = graphic;
792   CHARSET_FINAL         (cs) = final;
793   CHARSET_DOC_STRING    (cs) = doc;
794   CHARSET_REGISTRY      (cs) = reg;
795   CHARSET_CCL_PROGRAM   (cs) = Qnil;
796   CHARSET_REVERSE_DIRECTION_CHARSET (cs) = Qnil;
797 #ifdef UTF2000
798   CHARSET_DECODING_TABLE(cs) = decoding_table;
799   CHARSET_UCS_MIN(cs) = ucs_min;
800   CHARSET_UCS_MAX(cs) = ucs_max;
801   CHARSET_CODE_OFFSET(cs) = code_offset;
802   CHARSET_BYTE_OFFSET(cs) = byte_offset;
803 #endif
804   
805   switch ( CHARSET_TYPE (cs) )
806     {
807     case CHARSET_TYPE_94:
808       CHARSET_DIMENSION (cs) = 1;
809       CHARSET_CHARS (cs) = 94;
810 #ifdef UTF2000
811       if (!EQ (decoding_table, Qnil))
812         {
813           size_t i;
814           CHARSET_TO_BYTE1_TABLE(cs) = make_byte_from_character_table();
815           for (i = 0; i < 94; i++)
816             {
817               Lisp_Object c = XVECTOR_DATA(decoding_table)[i];
818
819               if (!EQ (c, Qnil))
820                 put_byte_from_character_table (XCHAR (c), i + 33,
821                                                CHARSET_TO_BYTE1_TABLE(cs));
822             }
823         }
824       else
825         CHARSET_TO_BYTE1_TABLE(cs) = NULL;
826       CHARSET_TO_BYTE2_TABLE(cs) = NULL;
827 #endif
828       break;
829     case CHARSET_TYPE_96:
830       CHARSET_DIMENSION (cs) = 1;
831       CHARSET_CHARS (cs) = 96;
832 #ifdef UTF2000
833       if (!EQ (decoding_table, Qnil))
834         {
835           size_t i;
836           CHARSET_TO_BYTE1_TABLE(cs) = make_byte_from_character_table();
837           for (i = 0; i < 96; i++)
838             {
839               Lisp_Object c = XVECTOR_DATA(decoding_table)[i];
840
841               if (!EQ (c, Qnil))
842                 put_byte_from_character_table (XCHAR (c), i + 32,
843                                                CHARSET_TO_BYTE1_TABLE(cs));
844             }
845         }
846       else
847         CHARSET_TO_BYTE1_TABLE(cs) = NULL;
848       CHARSET_TO_BYTE2_TABLE(cs) = NULL;
849 #endif
850       break;
851     case CHARSET_TYPE_94X94:
852       CHARSET_DIMENSION (cs) = 2;
853       CHARSET_CHARS (cs) = 94;
854 #ifdef UTF2000
855       CHARSET_TO_BYTE1_TABLE(cs) = NULL;
856       CHARSET_TO_BYTE2_TABLE(cs) = NULL;
857 #endif
858       break;
859     case CHARSET_TYPE_96X96:
860       CHARSET_DIMENSION (cs) = 2;
861       CHARSET_CHARS (cs) = 96;
862 #ifdef UTF2000
863       CHARSET_TO_BYTE1_TABLE(cs) = NULL;
864       CHARSET_TO_BYTE2_TABLE(cs) = NULL;
865 #endif
866       break;
867 #ifdef UTF2000
868     case CHARSET_TYPE_128X128:
869       CHARSET_DIMENSION (cs) = 2;
870       CHARSET_CHARS (cs) = 128;
871 #ifdef UTF2000
872       CHARSET_TO_BYTE1_TABLE(cs) = NULL;
873       CHARSET_TO_BYTE2_TABLE(cs) = NULL;
874 #endif
875       break;
876     case CHARSET_TYPE_256X256:
877       CHARSET_DIMENSION (cs) = 2;
878       CHARSET_CHARS (cs) = 256;
879 #ifdef UTF2000
880       CHARSET_TO_BYTE1_TABLE(cs) = NULL;
881       CHARSET_TO_BYTE2_TABLE(cs) = NULL;
882 #endif
883       break;
884 #endif
885     }
886
887 #ifndef UTF2000
888   if (id == LEADING_BYTE_ASCII)
889     CHARSET_REP_BYTES (cs) = 1;
890   else if (id < 0xA0)
891     CHARSET_REP_BYTES (cs) = CHARSET_DIMENSION (cs) + 1;
892   else
893     CHARSET_REP_BYTES (cs) = CHARSET_DIMENSION (cs) + 2;
894 #endif
895   
896   if (final)
897     {
898       /* some charsets do not have final characters.  This includes
899          ASCII, Control-1, Composite, and the two faux private
900          charsets. */
901 #if UTF2000
902       if (code_offset == 0)
903         {
904           assert (NILP (charset_by_attributes[type][final]));
905           charset_by_attributes[type][final] = obj;
906         }
907 #else
908       assert (NILP (charset_by_attributes[type][final][direction]));
909       charset_by_attributes[type][final][direction] = obj;
910 #endif
911     }
912
913   assert (NILP (charset_by_leading_byte[id - MIN_LEADING_BYTE]));
914   charset_by_leading_byte[id - MIN_LEADING_BYTE] = obj;
915 #ifndef UTF2000
916   if (id < 0xA0)
917     /* official leading byte */
918     rep_bytes_by_first_byte[id] = CHARSET_REP_BYTES (cs);
919 #endif
920
921   /* Some charsets are "faux" and don't have names or really exist at
922      all except in the leading-byte table. */
923   if (!NILP (name))
924     Fputhash (name, obj, Vcharset_hash_table);
925   return obj;
926 }
927
928 static int
929 get_unallocated_leading_byte (int dimension)
930 {
931   Charset_ID lb;
932
933   if (dimension == 1)
934     {
935       if (next_allocated_1_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_1)
936         lb = 0;
937       else
938         lb = next_allocated_1_byte_leading_byte++;
939     }
940   else
941     {
942       if (next_allocated_2_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_2)
943         lb = 0;
944       else
945         lb = next_allocated_2_byte_leading_byte++;
946     }
947
948   if (!lb)
949     signal_simple_error
950       ("No more character sets free for this dimension",
951        make_int (dimension));
952
953   return lb;
954 }
955
956 #ifdef UTF2000
957 unsigned char
958 charset_get_byte1 (Lisp_Object charset, Emchar ch)
959 {
960   Emchar_to_byte_table* table;
961   int d;
962
963   if ((table = XCHARSET_TO_BYTE1_TABLE (charset)) != NULL)
964     return get_byte_from_character_table (ch, table);
965   else if ((XCHARSET_UCS_MIN (charset) <= ch)
966            && (ch <= XCHARSET_UCS_MAX (charset)))
967     return (ch - XCHARSET_UCS_MIN (charset)
968             + XCHARSET_CODE_OFFSET (charset))
969       / (XCHARSET_DIMENSION (charset) == 1 ?
970          1
971          :
972          XCHARSET_DIMENSION (charset) == 2 ?
973          XCHARSET_CHARS (charset)
974          :
975          XCHARSET_DIMENSION (charset) == 3 ?
976          XCHARSET_CHARS (charset) * XCHARSET_CHARS (charset)
977          :
978          XCHARSET_CHARS (charset)
979          * XCHARSET_CHARS (charset) * XCHARSET_CHARS (charset))
980       + XCHARSET_BYTE_OFFSET (charset);
981   else if (XCHARSET_CODE_OFFSET (charset) == 0)
982     {
983       if (XCHARSET_DIMENSION (charset) == 1)
984         {
985           if (XCHARSET_CHARS (charset) == 94)
986             {
987               if (((d = ch - (MIN_CHAR_94
988                               + (XCHARSET_FINAL (charset) - '0') * 94)) >= 0)
989                   && (d < 94))
990                 return d + 33;
991             }
992           else if (XCHARSET_CHARS (charset) == 96)
993             {
994               if (((d = ch - (MIN_CHAR_96
995                               + (XCHARSET_FINAL (charset) - '0') * 96)) >= 0)
996                   && (d < 96))
997                 return d + 32;
998             }
999           else
1000             return 0;
1001         }
1002       else if (XCHARSET_DIMENSION (charset) == 2)
1003         {
1004           if (XCHARSET_CHARS (charset) == 94)
1005             {
1006               if (((d = ch - (MIN_CHAR_94x94
1007                               + (XCHARSET_FINAL (charset) - '0') * 94 * 94))
1008                    >= 0)
1009                   && (d < 94 * 94))
1010                 return (d / 94) + 33;
1011             }
1012           else if (XCHARSET_CHARS (charset) == 96)
1013             {
1014               if (((d = ch - (MIN_CHAR_96x96
1015                               + (XCHARSET_FINAL (charset) - '0') * 96 * 96))
1016                    >= 0)
1017                   && (d < 96 * 96))
1018                 return (d / 96) + 32;
1019             }
1020         }
1021     }
1022   return 0;
1023 }
1024
1025 unsigned char
1026 charset_get_byte2 (Lisp_Object charset, Emchar ch)
1027 {
1028   if (XCHARSET_DIMENSION (charset) == 1)
1029     return 0;
1030   else
1031     {
1032       Emchar_to_byte_table* table;
1033
1034       if ((table = XCHARSET_TO_BYTE2_TABLE (charset)) != NULL)
1035         return get_byte_from_character_table (ch, table);
1036       else if ((XCHARSET_UCS_MIN (charset) <= ch)
1037                && (ch <= XCHARSET_UCS_MAX (charset)))
1038         return ((ch - XCHARSET_UCS_MIN (charset)
1039                  + XCHARSET_CODE_OFFSET (charset))
1040                 / (XCHARSET_DIMENSION (charset) == 2 ?
1041                    1
1042                    :
1043                    XCHARSET_DIMENSION (charset) == 3 ?
1044                    XCHARSET_CHARS (charset)
1045                    :
1046                    XCHARSET_CHARS (charset) * XCHARSET_CHARS (charset)))
1047           % XCHARSET_CHARS (charset)
1048           + XCHARSET_BYTE_OFFSET (charset);
1049       else if (XCHARSET_CHARS (charset) == 94)
1050         return (MIN_CHAR_94x94
1051                 + (XCHARSET_FINAL (charset) - '0') * 94 * 94 <= ch)
1052           && (ch < MIN_CHAR_94x94
1053               + (XCHARSET_FINAL (charset) - '0' + 1) * 94 * 94) ?
1054           ((ch - MIN_CHAR_94x94) % 94) + 33 : 0;
1055       else /* if (XCHARSET_CHARS (charset) == 96) */
1056         return (MIN_CHAR_96x96
1057                 + (XCHARSET_FINAL (charset) - '0') * 96 * 96 <= ch)
1058           && (ch < MIN_CHAR_96x96
1059               + (XCHARSET_FINAL (charset) - '0' + 1) * 96 * 96) ?
1060           ((ch - MIN_CHAR_96x96) % 96) + 32 : 0;
1061     }
1062 }
1063
1064 Lisp_Object Vdefault_coded_charset_priority_list;
1065 #endif
1066
1067 \f
1068 /************************************************************************/
1069 /*                      Basic charset Lisp functions                    */
1070 /************************************************************************/
1071
1072 DEFUN ("charsetp", Fcharsetp, 1, 1, 0, /*
1073 Return non-nil if OBJECT is a charset.
1074 */
1075        (object))
1076 {
1077   return CHARSETP (object) ? Qt : Qnil;
1078 }
1079
1080 DEFUN ("find-charset", Ffind_charset, 1, 1, 0, /*
1081 Retrieve the charset of the given name.
1082 If CHARSET-OR-NAME is a charset object, it is simply returned.
1083 Otherwise, CHARSET-OR-NAME should be a symbol.  If there is no such charset,
1084 nil is returned.  Otherwise the associated charset object is returned.
1085 */
1086        (charset_or_name))
1087 {
1088   if (CHARSETP (charset_or_name))
1089     return charset_or_name;
1090
1091   CHECK_SYMBOL (charset_or_name);
1092   return Fgethash (charset_or_name, Vcharset_hash_table, Qnil);
1093 }
1094
1095 DEFUN ("get-charset", Fget_charset, 1, 1, 0, /*
1096 Retrieve the charset of the given name.
1097 Same as `find-charset' except an error is signalled if there is no such
1098 charset instead of returning nil.
1099 */
1100        (name))
1101 {
1102   Lisp_Object charset = Ffind_charset (name);
1103
1104   if (NILP (charset))
1105     signal_simple_error ("No such charset", name);
1106   return charset;
1107 }
1108
1109 /* We store the charsets in hash tables with the names as the key and the
1110    actual charset object as the value.  Occasionally we need to use them
1111    in a list format.  These routines provide us with that. */
1112 struct charset_list_closure
1113 {
1114   Lisp_Object *charset_list;
1115 };
1116
1117 static int
1118 add_charset_to_list_mapper (Lisp_Object key, Lisp_Object value,
1119                             void *charset_list_closure)
1120 {
1121   /* This function can GC */
1122   struct charset_list_closure *chcl =
1123     (struct charset_list_closure*) charset_list_closure;
1124   Lisp_Object *charset_list = chcl->charset_list;
1125
1126   *charset_list = Fcons (XCHARSET_NAME (value), *charset_list);
1127   return 0;
1128 }
1129
1130 DEFUN ("charset-list", Fcharset_list, 0, 0, 0, /*
1131 Return a list of the names of all defined charsets.
1132 */
1133        ())
1134 {
1135   Lisp_Object charset_list = Qnil;
1136   struct gcpro gcpro1;
1137   struct charset_list_closure charset_list_closure;
1138
1139   GCPRO1 (charset_list);
1140   charset_list_closure.charset_list = &charset_list;
1141   elisp_maphash (add_charset_to_list_mapper, Vcharset_hash_table,
1142                  &charset_list_closure);
1143   UNGCPRO;
1144
1145   return charset_list;
1146 }
1147
1148 DEFUN ("charset-name", Fcharset_name, 1, 1, 0, /*
1149 Return the name of the given charset.
1150 */
1151        (charset))
1152 {
1153   return XCHARSET_NAME (Fget_charset (charset));
1154 }
1155
1156 DEFUN ("make-charset", Fmake_charset, 3, 3, 0, /*
1157 Define a new character set.
1158 This function is for use with Mule support.
1159 NAME is a symbol, the name by which the character set is normally referred.
1160 DOC-STRING is a string describing the character set.
1161 PROPS is a property list, describing the specific nature of the
1162 character set.  Recognized properties are:
1163
1164 'short-name     Short version of the charset name (ex: Latin-1)
1165 'long-name      Long version of the charset name (ex: ISO8859-1 (Latin-1))
1166 'registry       A regular expression matching the font registry field for
1167                 this character set.
1168 'dimension      Number of octets used to index a character in this charset.
1169                 Either 1 or 2.  Defaults to 1.
1170 'columns        Number of columns used to display a character in this charset.
1171                 Only used in TTY mode. (Under X, the actual width of a
1172                 character can be derived from the font used to display the
1173                 characters.) If unspecified, defaults to the dimension
1174                 (this is almost always the correct value).
1175 'chars          Number of characters in each dimension (94 or 96).
1176                 Defaults to 94.  Note that if the dimension is 2, the
1177                 character set thus described is 94x94 or 96x96.
1178 'final          Final byte of ISO 2022 escape sequence.  Must be
1179                 supplied.  Each combination of (DIMENSION, CHARS) defines a
1180                 separate namespace for final bytes.  Note that ISO
1181                 2022 restricts the final byte to the range
1182                 0x30 - 0x7E if dimension == 1, and 0x30 - 0x5F if
1183                 dimension == 2.  Note also that final bytes in the range
1184                 0x30 - 0x3F are reserved for user-defined (not official)
1185                 character sets.
1186 'graphic        0 (use left half of font on output) or 1 (use right half
1187                 of font on output).  Defaults to 0.  For example, for
1188                 a font whose registry is ISO8859-1, the left half
1189                 (octets 0x20 - 0x7F) is the `ascii' character set, while
1190                 the right half (octets 0xA0 - 0xFF) is the `latin-1'
1191                 character set.  With 'graphic set to 0, the octets
1192                 will have their high bit cleared; with it set to 1,
1193                 the octets will have their high bit set.
1194 'direction      'l2r (left-to-right) or 'r2l (right-to-left).
1195                 Defaults to 'l2r.
1196 'ccl-program    A compiled CCL program used to convert a character in
1197                 this charset into an index into the font.  This is in
1198                 addition to the 'graphic property.  The CCL program
1199                 is passed the octets of the character, with the high
1200                 bit cleared and set depending upon whether the value
1201                 of the 'graphic property is 0 or 1.
1202 */
1203        (name, doc_string, props))
1204 {
1205   int id, dimension = 1, chars = 94, graphic = 0, final = 0, columns = -1;
1206   int direction = CHARSET_LEFT_TO_RIGHT;
1207   int type;
1208   Lisp_Object registry = Qnil;
1209   Lisp_Object charset;
1210   Lisp_Object rest, keyword, value;
1211   Lisp_Object ccl_program = Qnil;
1212   Lisp_Object short_name = Qnil, long_name = Qnil;
1213
1214   CHECK_SYMBOL (name);
1215   if (!NILP (doc_string))
1216     CHECK_STRING (doc_string);
1217
1218   charset = Ffind_charset (name);
1219   if (!NILP (charset))
1220     signal_simple_error ("Cannot redefine existing charset", name);
1221
1222   EXTERNAL_PROPERTY_LIST_LOOP (rest, keyword, value, props)
1223     {
1224       if (EQ (keyword, Qshort_name))
1225         {
1226           CHECK_STRING (value);
1227           short_name = value;
1228         }
1229
1230       if (EQ (keyword, Qlong_name))
1231         {
1232           CHECK_STRING (value);
1233           long_name = value;
1234         }
1235
1236       else if (EQ (keyword, Qdimension))
1237         {
1238           CHECK_INT (value);
1239           dimension = XINT (value);
1240           if (dimension < 1 || dimension > 2)
1241             signal_simple_error ("Invalid value for 'dimension", value);
1242         }
1243
1244       else if (EQ (keyword, Qchars))
1245         {
1246           CHECK_INT (value);
1247           chars = XINT (value);
1248           if (chars != 94 && chars != 96)
1249             signal_simple_error ("Invalid value for 'chars", value);
1250         }
1251
1252       else if (EQ (keyword, Qcolumns))
1253         {
1254           CHECK_INT (value);
1255           columns = XINT (value);
1256           if (columns != 1 && columns != 2)
1257             signal_simple_error ("Invalid value for 'columns", value);
1258         }
1259
1260       else if (EQ (keyword, Qgraphic))
1261         {
1262           CHECK_INT (value);
1263           graphic = XINT (value);
1264           if (graphic < 0 || graphic > 1)
1265             signal_simple_error ("Invalid value for 'graphic", value);
1266         }
1267
1268       else if (EQ (keyword, Qregistry))
1269         {
1270           CHECK_STRING (value);
1271           registry = value;
1272         }
1273
1274       else if (EQ (keyword, Qdirection))
1275         {
1276           if (EQ (value, Ql2r))
1277             direction = CHARSET_LEFT_TO_RIGHT;
1278           else if (EQ (value, Qr2l))
1279             direction = CHARSET_RIGHT_TO_LEFT;
1280           else
1281             signal_simple_error ("Invalid value for 'direction", value);
1282         }
1283
1284       else if (EQ (keyword, Qfinal))
1285         {
1286           CHECK_CHAR_COERCE_INT (value);
1287           final = XCHAR (value);
1288           if (final < '0' || final > '~')
1289             signal_simple_error ("Invalid value for 'final", value);
1290         }
1291
1292       else if (EQ (keyword, Qccl_program))
1293         {
1294           CHECK_VECTOR (value);
1295           ccl_program = value;
1296         }
1297
1298       else
1299         signal_simple_error ("Unrecognized property", keyword);
1300     }
1301
1302   if (!final)
1303     error ("'final must be specified");
1304   if (dimension == 2 && final > 0x5F)
1305     signal_simple_error
1306       ("Final must be in the range 0x30 - 0x5F for dimension == 2",
1307        make_char (final));
1308
1309   if (dimension == 1)
1310     type = (chars == 94) ? CHARSET_TYPE_94    : CHARSET_TYPE_96;
1311   else
1312     type = (chars == 94) ? CHARSET_TYPE_94X94 : CHARSET_TYPE_96X96;
1313
1314   if (!NILP (CHARSET_BY_ATTRIBUTES (type, final, CHARSET_LEFT_TO_RIGHT)) ||
1315       !NILP (CHARSET_BY_ATTRIBUTES (type, final, CHARSET_RIGHT_TO_LEFT)))
1316     error
1317       ("Character set already defined for this DIMENSION/CHARS/FINAL combo");
1318
1319 #ifdef UTF2000
1320   if (dimension == 1)
1321     {
1322       if (chars == 94)
1323         {
1324           /* id = CHARSET_ID_OFFSET_94 + final; */
1325           id = get_unallocated_leading_byte (dimension);
1326         }
1327       else if (chars == 96)
1328         {
1329           id = get_unallocated_leading_byte (dimension);
1330         }
1331       else
1332         {
1333           abort ();
1334         }
1335     }
1336   else if (dimension == 2)
1337     {
1338       if (chars == 94)
1339         {
1340           id = get_unallocated_leading_byte (dimension);
1341         }
1342       else if (chars == 96)
1343         {
1344           id = get_unallocated_leading_byte (dimension);
1345         }
1346       else
1347         {
1348           abort ();
1349         }
1350     }
1351   else
1352     {
1353       abort ();
1354     }
1355 #else
1356   id = get_unallocated_leading_byte (dimension);
1357 #endif
1358
1359   if (NILP (doc_string))
1360     doc_string = build_string ("");
1361
1362   if (NILP (registry))
1363     registry = build_string ("");
1364
1365   if (NILP (short_name))
1366     XSETSTRING (short_name, XSYMBOL (name)->name);
1367
1368   if (NILP (long_name))
1369     long_name = doc_string;
1370
1371   if (columns == -1)
1372     columns = dimension;
1373   charset = make_charset (id, name, type, columns, graphic,
1374                           final, direction, short_name, long_name,
1375                           doc_string, registry,
1376                           Qnil, 0, 0, 0, 0);
1377   if (!NILP (ccl_program))
1378     XCHARSET_CCL_PROGRAM (charset) = ccl_program;
1379   return charset;
1380 }
1381
1382 DEFUN ("make-reverse-direction-charset", Fmake_reverse_direction_charset,
1383        2, 2, 0, /*
1384 Make a charset equivalent to CHARSET but which goes in the opposite direction.
1385 NEW-NAME is the name of the new charset.  Return the new charset.
1386 */
1387        (charset, new_name))
1388 {
1389   Lisp_Object new_charset = Qnil;
1390   int id, dimension, columns, graphic, final;
1391   int direction, type;
1392   Lisp_Object registry, doc_string, short_name, long_name;
1393   struct Lisp_Charset *cs;
1394
1395   charset = Fget_charset (charset);
1396   if (!NILP (XCHARSET_REVERSE_DIRECTION_CHARSET (charset)))
1397     signal_simple_error ("Charset already has reverse-direction charset",
1398                          charset);
1399
1400   CHECK_SYMBOL (new_name);
1401   if (!NILP (Ffind_charset (new_name)))
1402     signal_simple_error ("Cannot redefine existing charset", new_name);
1403
1404   cs = XCHARSET (charset);
1405
1406   type      = CHARSET_TYPE      (cs);
1407   columns   = CHARSET_COLUMNS   (cs);
1408   dimension = CHARSET_DIMENSION (cs);
1409   id = get_unallocated_leading_byte (dimension);
1410
1411   graphic = CHARSET_GRAPHIC (cs);
1412   final = CHARSET_FINAL (cs);
1413   direction = CHARSET_RIGHT_TO_LEFT;
1414   if (CHARSET_DIRECTION (cs) == CHARSET_RIGHT_TO_LEFT)
1415     direction = CHARSET_LEFT_TO_RIGHT;
1416   doc_string = CHARSET_DOC_STRING (cs);
1417   short_name = CHARSET_SHORT_NAME (cs);
1418   long_name = CHARSET_LONG_NAME (cs);
1419   registry = CHARSET_REGISTRY (cs);
1420
1421   new_charset = make_charset (id, new_name, type, columns,
1422                               graphic, final, direction, short_name, long_name,
1423                               doc_string, registry,
1424 #ifdef UTF2000
1425                               CHARSET_DECODING_TABLE(cs),
1426                               CHARSET_UCS_MIN(cs),
1427                               CHARSET_UCS_MAX(cs),
1428                               CHARSET_CODE_OFFSET(cs),
1429                               CHARSET_BYTE_OFFSET(cs)
1430 #else
1431                               Qnil, 0, 0, 0
1432 #endif
1433 );
1434
1435   CHARSET_REVERSE_DIRECTION_CHARSET (cs) = new_charset;
1436   XCHARSET_REVERSE_DIRECTION_CHARSET (new_charset) = charset;
1437
1438   return new_charset;
1439 }
1440
1441 /* #### Reverse direction charsets not yet implemented.  */
1442 #if 0
1443 DEFUN ("charset-reverse-direction-charset", Fcharset_reverse_direction_charset,
1444        1, 1, 0, /*
1445 Return the reverse-direction charset parallel to CHARSET, if any.
1446 This is the charset with the same properties (in particular, the same
1447 dimension, number of characters per dimension, and final byte) as
1448 CHARSET but whose characters are displayed in the opposite direction.
1449 */
1450        (charset))
1451 {
1452   charset = Fget_charset (charset);
1453   return XCHARSET_REVERSE_DIRECTION_CHARSET (charset);
1454 }
1455 #endif
1456
1457 DEFUN ("charset-from-attributes", Fcharset_from_attributes, 3, 4, 0, /*
1458 Return a charset with the given DIMENSION, CHARS, FINAL, and DIRECTION.
1459 If DIRECTION is omitted, both directions will be checked (left-to-right
1460 will be returned if character sets exist for both directions).
1461 */
1462        (dimension, chars, final, direction))
1463 {
1464   int dm, ch, fi, di = -1;
1465   int type;
1466   Lisp_Object obj = Qnil;
1467
1468   CHECK_INT (dimension);
1469   dm = XINT (dimension);
1470   if (dm < 1 || dm > 2)
1471     signal_simple_error ("Invalid value for DIMENSION", dimension);
1472
1473   CHECK_INT (chars);
1474   ch = XINT (chars);
1475   if (ch != 94 && ch != 96)
1476     signal_simple_error ("Invalid value for CHARS", chars);
1477
1478   CHECK_CHAR_COERCE_INT (final);
1479   fi = XCHAR (final);
1480   if (fi < '0' || fi > '~')
1481     signal_simple_error ("Invalid value for FINAL", final);
1482
1483   if (EQ (direction, Ql2r))
1484     di = CHARSET_LEFT_TO_RIGHT;
1485   else if (EQ (direction, Qr2l))
1486     di = CHARSET_RIGHT_TO_LEFT;
1487   else if (!NILP (direction))
1488     signal_simple_error ("Invalid value for DIRECTION", direction);
1489
1490   if (dm == 2 && fi > 0x5F)
1491     signal_simple_error
1492       ("Final must be in the range 0x30 - 0x5F for dimension == 2", final);
1493
1494   if (dm == 1)
1495     type = (ch == 94) ? CHARSET_TYPE_94    : CHARSET_TYPE_96;
1496   else
1497     type = (ch == 94) ? CHARSET_TYPE_94X94 : CHARSET_TYPE_96X96;
1498
1499   if (di == -1)
1500     {
1501       obj = CHARSET_BY_ATTRIBUTES (type, fi, CHARSET_LEFT_TO_RIGHT);
1502       if (NILP (obj))
1503         obj = CHARSET_BY_ATTRIBUTES (type, fi, CHARSET_RIGHT_TO_LEFT);
1504     }
1505   else
1506     obj = CHARSET_BY_ATTRIBUTES (type, fi, di);
1507
1508   if (CHARSETP (obj))
1509     return XCHARSET_NAME (obj);
1510   return obj;
1511 }
1512
1513 DEFUN ("charset-short-name", Fcharset_short_name, 1, 1, 0, /*
1514 Return short name of CHARSET.
1515 */
1516        (charset))
1517 {
1518   return XCHARSET_SHORT_NAME (Fget_charset (charset));
1519 }
1520
1521 DEFUN ("charset-long-name", Fcharset_long_name, 1, 1, 0, /*
1522 Return long name of CHARSET.
1523 */
1524        (charset))
1525 {
1526   return XCHARSET_LONG_NAME (Fget_charset (charset));
1527 }
1528
1529 DEFUN ("charset-description", Fcharset_description, 1, 1, 0, /*
1530 Return description of CHARSET.
1531 */
1532        (charset))
1533 {
1534   return XCHARSET_DOC_STRING (Fget_charset (charset));
1535 }
1536
1537 DEFUN ("charset-dimension", Fcharset_dimension, 1, 1, 0, /*
1538 Return dimension of CHARSET.
1539 */
1540        (charset))
1541 {
1542   return make_int (XCHARSET_DIMENSION (Fget_charset (charset)));
1543 }
1544
1545 DEFUN ("charset-property", Fcharset_property, 2, 2, 0, /*
1546 Return property PROP of CHARSET.
1547 Recognized properties are those listed in `make-charset', as well as
1548 'name and 'doc-string.
1549 */
1550        (charset, prop))
1551 {
1552   struct Lisp_Charset *cs;
1553
1554   charset = Fget_charset (charset);
1555   cs = XCHARSET (charset);
1556
1557   CHECK_SYMBOL (prop);
1558   if (EQ (prop, Qname))        return CHARSET_NAME (cs);
1559   if (EQ (prop, Qshort_name))  return CHARSET_SHORT_NAME (cs);
1560   if (EQ (prop, Qlong_name))   return CHARSET_LONG_NAME (cs);
1561   if (EQ (prop, Qdoc_string))  return CHARSET_DOC_STRING (cs);
1562   if (EQ (prop, Qdimension))   return make_int (CHARSET_DIMENSION (cs));
1563   if (EQ (prop, Qcolumns))     return make_int (CHARSET_COLUMNS (cs));
1564   if (EQ (prop, Qgraphic))     return make_int (CHARSET_GRAPHIC (cs));
1565   if (EQ (prop, Qfinal))       return make_char (CHARSET_FINAL (cs));
1566   if (EQ (prop, Qchars))       return make_int (CHARSET_CHARS (cs));
1567   if (EQ (prop, Qregistry))    return CHARSET_REGISTRY (cs);
1568   if (EQ (prop, Qccl_program)) return CHARSET_CCL_PROGRAM (cs);
1569   if (EQ (prop, Qdirection))
1570     return CHARSET_DIRECTION (cs) == CHARSET_LEFT_TO_RIGHT ? Ql2r : Qr2l;
1571   if (EQ (prop, Qreverse_direction_charset))
1572     {
1573       Lisp_Object obj = CHARSET_REVERSE_DIRECTION_CHARSET (cs);
1574       if (NILP (obj))
1575         return Qnil;
1576       else
1577         return XCHARSET_NAME (obj);
1578     }
1579   signal_simple_error ("Unrecognized charset property name", prop);
1580   return Qnil; /* not reached */
1581 }
1582
1583 DEFUN ("charset-id", Fcharset_id, 1, 1, 0, /*
1584 Return charset identification number of CHARSET.
1585 */
1586         (charset))
1587 {
1588   return make_int(XCHARSET_LEADING_BYTE (Fget_charset (charset)));
1589 }
1590
1591 /* #### We need to figure out which properties we really want to
1592    allow to be set. */
1593
1594 DEFUN ("set-charset-ccl-program", Fset_charset_ccl_program, 2, 2, 0, /*
1595 Set the 'ccl-program property of CHARSET to CCL-PROGRAM.
1596 */
1597        (charset, ccl_program))
1598 {
1599   charset = Fget_charset (charset);
1600   CHECK_VECTOR (ccl_program);
1601   XCHARSET_CCL_PROGRAM (charset) = ccl_program;
1602   return Qnil;
1603 }
1604
1605 static void
1606 invalidate_charset_font_caches (Lisp_Object charset)
1607 {
1608   /* Invalidate font cache entries for charset on all devices. */
1609   Lisp_Object devcons, concons, hash_table;
1610   DEVICE_LOOP_NO_BREAK (devcons, concons)
1611     {
1612       struct device *d = XDEVICE (XCAR (devcons));
1613       hash_table = Fgethash (charset, d->charset_font_cache, Qunbound);
1614       if (!UNBOUNDP (hash_table))
1615         Fclrhash (hash_table);
1616     }
1617 }
1618
1619 DEFUN ("set-charset-registry", Fset_charset_registry, 2, 2, 0, /*
1620 Set the 'registry property of CHARSET to REGISTRY.
1621 */
1622        (charset, registry))
1623 {
1624   charset = Fget_charset (charset);
1625   CHECK_STRING (registry);
1626   XCHARSET_REGISTRY (charset) = registry;
1627   invalidate_charset_font_caches (charset);
1628   face_property_was_changed (Vdefault_face, Qfont, Qglobal);
1629   return Qnil;
1630 }
1631
1632 #ifdef UTF2000
1633 DEFUN ("charset-mapping-table", Fcharset_mapping_table, 1, 1, 0, /*
1634 Set the 'registry property of CHARSET to REGISTRY.
1635 */
1636        (charset))
1637 {
1638   return XCHARSET_DECODING_TABLE (Fget_charset (charset));
1639 }
1640 #endif
1641
1642 \f
1643 /************************************************************************/
1644 /*              Lisp primitives for working with characters             */
1645 /************************************************************************/
1646
1647 DEFUN ("make-char", Fmake_char, 2, 3, 0, /*
1648 Make a character from CHARSET and octets ARG1 and ARG2.
1649 ARG2 is required only for characters from two-dimensional charsets.
1650 For example, (make-char 'latin-iso8859-2 185) will return the Latin 2
1651 character s with caron.
1652 */
1653        (charset, arg1, arg2))
1654 {
1655   struct Lisp_Charset *cs;
1656   int a1, a2;
1657   int lowlim, highlim;
1658
1659   charset = Fget_charset (charset);
1660   cs = XCHARSET (charset);
1661
1662   if      (EQ (charset, Vcharset_ascii))     lowlim =  0, highlim = 127;
1663   else if (EQ (charset, Vcharset_control_1)) lowlim =  0, highlim =  31;
1664 #ifdef UTF2000
1665   else if (CHARSET_CHARS (cs) == 256)        lowlim =  0, highlim = 255;
1666 #endif
1667   else if (CHARSET_CHARS (cs) == 94)         lowlim = 33, highlim = 126;
1668   else  /* CHARSET_CHARS (cs) == 96) */      lowlim = 32, highlim = 127;
1669
1670   CHECK_INT (arg1);
1671   /* It is useful (and safe, according to Olivier Galibert) to strip
1672      the 8th bit off ARG1 and ARG2 becaue it allows programmers to
1673      write (make-char 'latin-iso8859-2 CODE) where code is the actual
1674      Latin 2 code of the character.  */
1675 #ifdef UTF2000
1676   a1 = XINT (arg1);
1677   if (highlim < 128)
1678     a1 &= 0x7f;
1679 #else
1680   a1 = XINT (arg1);
1681 #endif
1682   if (a1 < lowlim || a1 > highlim)
1683     args_out_of_range_3 (arg1, make_int (lowlim), make_int (highlim));
1684
1685   if (CHARSET_DIMENSION (cs) == 1)
1686     {
1687       if (!NILP (arg2))
1688         signal_simple_error
1689           ("Charset is of dimension one; second octet must be nil", arg2);
1690       return make_char (MAKE_CHAR (charset, a1, 0));
1691     }
1692
1693   CHECK_INT (arg2);
1694 #ifdef UTF2000
1695   a2 = XINT (arg2);
1696   if (highlim < 128)
1697     a2 &= 0x7f;
1698 #else
1699   a2 = XINT (arg2) & 0x7f;
1700 #endif
1701   if (a2 < lowlim || a2 > highlim)
1702     args_out_of_range_3 (arg2, make_int (lowlim), make_int (highlim));
1703
1704   return make_char (MAKE_CHAR (charset, a1, a2));
1705 }
1706
1707 DEFUN ("char-charset", Fchar_charset, 1, 1, 0, /*
1708 Return the character set of char CH.
1709 */
1710        (ch))
1711 {
1712   CHECK_CHAR_COERCE_INT (ch);
1713
1714   return XCHARSET_NAME (CHAR_CHARSET (XCHAR (ch)));
1715 }
1716
1717 DEFUN ("split-char", Fsplit_char, 1, 1, 0, /*
1718 Return list of charset and one or two position-codes of CHAR.
1719 */
1720        (character))
1721 {
1722   /* This function can GC */
1723   struct gcpro gcpro1, gcpro2;
1724   Lisp_Object charset = Qnil;
1725   Lisp_Object rc = Qnil;
1726   int c1, c2;
1727
1728   GCPRO2 (charset, rc);
1729   CHECK_CHAR_COERCE_INT (character);
1730
1731   BREAKUP_CHAR (XCHAR (character), charset, c1, c2);
1732
1733   if (XCHARSET_DIMENSION (Fget_charset (charset)) == 2)
1734     {
1735       rc = list3 (XCHARSET_NAME (charset), make_int (c1), make_int (c2));
1736     }
1737   else
1738     {
1739       rc = list2 (XCHARSET_NAME (charset), make_int (c1));
1740     }
1741   UNGCPRO;
1742
1743   return rc;
1744 }
1745
1746 \f
1747 #ifdef ENABLE_COMPOSITE_CHARS
1748 /************************************************************************/
1749 /*                     composite character functions                    */
1750 /************************************************************************/
1751
1752 Emchar
1753 lookup_composite_char (Bufbyte *str, int len)
1754 {
1755   Lisp_Object lispstr = make_string (str, len);
1756   Lisp_Object ch = Fgethash (lispstr,
1757                              Vcomposite_char_string2char_hash_table,
1758                              Qunbound);
1759   Emchar emch;
1760
1761   if (UNBOUNDP (ch))
1762     {
1763       if (composite_char_row_next >= 128)
1764         signal_simple_error ("No more composite chars available", lispstr);
1765       emch = MAKE_CHAR (Vcharset_composite, composite_char_row_next,
1766                         composite_char_col_next);
1767       Fputhash (make_char (emch), lispstr,
1768                 Vcomposite_char_char2string_hash_table);
1769       Fputhash (lispstr, make_char (emch),
1770                 Vcomposite_char_string2char_hash_table);
1771       composite_char_col_next++;
1772       if (composite_char_col_next >= 128)
1773         {
1774           composite_char_col_next = 32;
1775           composite_char_row_next++;
1776         }
1777     }
1778   else
1779     emch = XCHAR (ch);
1780   return emch;
1781 }
1782
1783 Lisp_Object
1784 composite_char_string (Emchar ch)
1785 {
1786   Lisp_Object str = Fgethash (make_char (ch),
1787                               Vcomposite_char_char2string_hash_table,
1788                               Qunbound);
1789   assert (!UNBOUNDP (str));
1790   return str;
1791 }
1792
1793 xxDEFUN ("make-composite-char", Fmake_composite_char, 1, 1, 0, /*
1794 Convert a string into a single composite character.
1795 The character is the result of overstriking all the characters in
1796 the string.
1797 */
1798        (string))
1799 {
1800   CHECK_STRING (string);
1801   return make_char (lookup_composite_char (XSTRING_DATA (string),
1802                                            XSTRING_LENGTH (string)));
1803 }
1804
1805 xxDEFUN ("composite-char-string", Fcomposite_char_string, 1, 1, 0, /*
1806 Return a string of the characters comprising a composite character.
1807 */
1808        (ch))
1809 {
1810   Emchar emch;
1811
1812   CHECK_CHAR (ch);
1813   emch = XCHAR (ch);
1814   if (CHAR_LEADING_BYTE (emch) != LEADING_BYTE_COMPOSITE)
1815     signal_simple_error ("Must be composite char", ch);
1816   return composite_char_string (emch);
1817 }
1818 #endif /* ENABLE_COMPOSITE_CHARS */
1819
1820 \f
1821 /************************************************************************/
1822 /*                            initialization                            */
1823 /************************************************************************/
1824
1825 void
1826 syms_of_mule_charset (void)
1827 {
1828   DEFSUBR (Fcharsetp);
1829   DEFSUBR (Ffind_charset);
1830   DEFSUBR (Fget_charset);
1831   DEFSUBR (Fcharset_list);
1832   DEFSUBR (Fcharset_name);
1833   DEFSUBR (Fmake_charset);
1834   DEFSUBR (Fmake_reverse_direction_charset);
1835   /*  DEFSUBR (Freverse_direction_charset); */
1836   DEFSUBR (Fcharset_from_attributes);
1837   DEFSUBR (Fcharset_short_name);
1838   DEFSUBR (Fcharset_long_name);
1839   DEFSUBR (Fcharset_description);
1840   DEFSUBR (Fcharset_dimension);
1841   DEFSUBR (Fcharset_property);
1842   DEFSUBR (Fcharset_id);
1843   DEFSUBR (Fset_charset_ccl_program);
1844   DEFSUBR (Fset_charset_registry);
1845 #ifdef UTF2000
1846   DEFSUBR (Fcharset_mapping_table);
1847 #endif
1848
1849   DEFSUBR (Fmake_char);
1850   DEFSUBR (Fchar_charset);
1851   DEFSUBR (Fsplit_char);
1852
1853 #ifdef ENABLE_COMPOSITE_CHARS
1854   DEFSUBR (Fmake_composite_char);
1855   DEFSUBR (Fcomposite_char_string);
1856 #endif
1857
1858   defsymbol (&Qcharsetp, "charsetp");
1859   defsymbol (&Qregistry, "registry");
1860   defsymbol (&Qfinal, "final");
1861   defsymbol (&Qgraphic, "graphic");
1862   defsymbol (&Qdirection, "direction");
1863   defsymbol (&Qreverse_direction_charset, "reverse-direction-charset");
1864   defsymbol (&Qshort_name, "short-name");
1865   defsymbol (&Qlong_name, "long-name");
1866
1867   defsymbol (&Ql2r, "l2r");
1868   defsymbol (&Qr2l, "r2l");
1869
1870   /* Charsets, compatible with FSF 20.3
1871      Naming convention is Script-Charset[-Edition] */
1872   defsymbol (&Qascii,                   "ascii");
1873   defsymbol (&Qcontrol_1,               "control-1");
1874   defsymbol (&Qlatin_iso8859_1,         "latin-iso8859-1");
1875   defsymbol (&Qlatin_iso8859_2,         "latin-iso8859-2");
1876   defsymbol (&Qlatin_iso8859_3,         "latin-iso8859-3");
1877   defsymbol (&Qlatin_iso8859_4,         "latin-iso8859-4");
1878   defsymbol (&Qthai_tis620,             "thai-tis620");
1879   defsymbol (&Qgreek_iso8859_7,         "greek-iso8859-7");
1880   defsymbol (&Qarabic_iso8859_6,        "arabic-iso8859-6");
1881   defsymbol (&Qhebrew_iso8859_8,        "hebrew-iso8859-8");
1882   defsymbol (&Qkatakana_jisx0201,       "katakana-jisx0201");
1883   defsymbol (&Qlatin_jisx0201,          "latin-jisx0201");
1884   defsymbol (&Qcyrillic_iso8859_5,      "cyrillic-iso8859-5");
1885   defsymbol (&Qlatin_iso8859_9,         "latin-iso8859-9");
1886   defsymbol (&Qjapanese_jisx0208_1978,  "japanese-jisx0208-1978");
1887   defsymbol (&Qchinese_gb2312,          "chinese-gb2312");
1888   defsymbol (&Qjapanese_jisx0208,       "japanese-jisx0208");
1889   defsymbol (&Qkorean_ksc5601,          "korean-ksc5601");
1890   defsymbol (&Qjapanese_jisx0212,       "japanese-jisx0212");
1891   defsymbol (&Qchinese_cns11643_1,      "chinese-cns11643-1");
1892   defsymbol (&Qchinese_cns11643_2,      "chinese-cns11643-2");
1893 #ifdef UTF2000
1894   defsymbol (&Qucs_bmp,                 "ucs-bmp");
1895   defsymbol (&Qlatin_viscii_lower,      "vietnamese-viscii-lower");
1896   defsymbol (&Qlatin_viscii_upper,      "vietnamese-viscii-upper");
1897   defsymbol (&Qhiragana_jisx0208,       "hiragana-jisx0208");
1898   defsymbol (&Qkatakana_jisx0208,       "katakana-jisx0208");
1899 #endif
1900   defsymbol (&Qchinese_big5_1,          "chinese-big5-1");
1901   defsymbol (&Qchinese_big5_2,          "chinese-big5-2");
1902
1903   defsymbol (&Qcomposite,               "composite");
1904 }
1905
1906 void
1907 vars_of_mule_charset (void)
1908 {
1909   int i, j;
1910 #ifndef UTF2000
1911   int k;
1912 #endif
1913
1914   /* Table of charsets indexed by leading byte. */
1915   for (i = 0; i < countof (charset_by_leading_byte); i++)
1916     charset_by_leading_byte[i] = Qnil;
1917
1918 #ifdef UTF2000
1919   /* Table of charsets indexed by type/final-byte. */
1920   for (i = 0; i < countof (charset_by_attributes); i++)
1921     for (j = 0; j < countof (charset_by_attributes[0]); j++)
1922         charset_by_attributes[i][j] = Qnil;
1923 #else
1924   /* Table of charsets indexed by type/final-byte/direction. */
1925   for (i = 0; i < countof (charset_by_attributes); i++)
1926     for (j = 0; j < countof (charset_by_attributes[0]); j++)
1927       for (k = 0; k < countof (charset_by_attributes[0][0]); k++)
1928         charset_by_attributes[i][j][k] = Qnil;
1929 #endif
1930
1931   next_allocated_1_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_1;
1932 #ifdef UTF2000
1933   next_allocated_2_byte_leading_byte = LEADING_BYTE_CHINESE_BIG5_2 + 1;
1934 #else
1935   next_allocated_2_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_2;
1936 #endif
1937
1938 #ifndef UTF2000
1939   leading_code_private_11 = PRE_LEADING_BYTE_PRIVATE_1;
1940   DEFVAR_INT ("leading-code-private-11", &leading_code_private_11 /*
1941 Leading-code of private TYPE9N charset of column-width 1.
1942 */ );
1943   leading_code_private_11 = PRE_LEADING_BYTE_PRIVATE_1;
1944 #endif
1945
1946 #ifdef UTF2000
1947   Vutf_2000_version = build_string("0.8 (Kami)");
1948   DEFVAR_LISP ("utf-2000-version", &Vutf_2000_version /*
1949 Version number of UTF-2000.
1950 */ );
1951
1952   Vdefault_coded_charset_priority_list = Qnil;
1953   DEFVAR_LISP ("default-coded-charset-priority-list",
1954                &Vdefault_coded_charset_priority_list /*
1955 Default order of preferred coded-character-set.
1956 */ );
1957 #endif
1958 }
1959
1960 void
1961 complex_vars_of_mule_charset (void)
1962 {
1963   staticpro (&Vcharset_hash_table);
1964   Vcharset_hash_table =
1965     make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
1966
1967   /* Predefined character sets.  We store them into variables for
1968      ease of access. */
1969
1970 #ifdef UTF2000
1971   staticpro (&latin_jisx0201_to_ucs);
1972   latin_jisx0201_to_ucs = make_vector (94, Qnil);
1973   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x21 - 33]
1974     = make_char (0x0021) /* EXCLAMATION MARK */;
1975   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x22 - 33]
1976     = make_char (0x0022) /* QUOTATION MARK */;
1977   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x23 - 33]
1978     = make_char (0x0023) /* NUMBER SIGN */;
1979   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x24 - 33]
1980     = make_char (0x0024) /* DOLLAR SIGN */;
1981   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x25 - 33]
1982     = make_char (0x0025) /* PERCENT SIGN */;
1983   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x26 - 33]
1984     = make_char (0x0026) /* AMPERSAND */;
1985   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x27 - 33]
1986     = make_char (0x0027) /* APOSTROPHE */;
1987   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x28 - 33]
1988     = make_char (0x0028) /* LEFT PARENTHESIS */;
1989   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x29 - 33]
1990     = make_char (0x0029) /* RIGHT PARENTHESIS */;
1991   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x2A - 33]
1992     = make_char (0x002A) /* ASTERISK */;
1993   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x2B - 33]
1994     = make_char (0x002B) /* PLUS SIGN */;
1995   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x2C - 33]
1996     = make_char (0x002C) /* COMMA */;
1997   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x2D - 33]
1998     = make_char (0x002D) /* HYPHEN-MINUS */;
1999   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x2E - 33]
2000     = make_char (0x002E) /* FULL STOP */;
2001   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x2F - 33]
2002     = make_char (0x002F) /* SOLIDUS */;
2003   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x30 - 33]
2004     = make_char (0x0030) /* DIGIT ZERO */;
2005   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x31 - 33]
2006     = make_char (0x0031) /* DIGIT ONE */;
2007   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x32 - 33]
2008     = make_char (0x0032) /* DIGIT TWO */;
2009   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x33 - 33]
2010     = make_char (0x0033) /* DIGIT THREE */;
2011   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x34 - 33]
2012     = make_char (0x0034) /* DIGIT FOUR */;
2013   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x35 - 33]
2014     = make_char (0x0035) /* DIGIT FIVE */;
2015   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x36 - 33]
2016     = make_char (0x0036) /* DIGIT SIX */;
2017   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x37 - 33]
2018     = make_char (0x0037) /* DIGIT SEVEN */;
2019   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x38 - 33]
2020     = make_char (0x0038) /* DIGIT EIGHT */;
2021   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x39 - 33]
2022     = make_char (0x0039) /* DIGIT NINE */;
2023   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x3A - 33]
2024     = make_char (0x003A) /* COLON */;
2025   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x3B - 33]
2026     = make_char (0x003B) /* SEMICOLON */;
2027   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x3C - 33]
2028     = make_char (0x003C) /* LESS-THAN SIGN */;
2029   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x3D - 33]
2030     = make_char (0x003D) /* EQUALS SIGN */;
2031   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x3E - 33]
2032     = make_char (0x003E) /* GREATER-THAN SIGN */;
2033   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x3F - 33]
2034     = make_char (0x003F) /* QUESTION MARK */;
2035   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x40 - 33]
2036     = make_char (0x0040) /* COMMERCIAL AT */;
2037   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x41 - 33]
2038     = make_char (0x0041) /* LATIN CAPITAL LETTER A */;
2039   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x42 - 33]
2040     = make_char (0x0042) /* LATIN CAPITAL LETTER B */;
2041   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x43 - 33]
2042     = make_char (0x0043) /* LATIN CAPITAL LETTER C */;
2043   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x44 - 33]
2044     = make_char (0x0044) /* LATIN CAPITAL LETTER D */;
2045   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x45 - 33]
2046     = make_char (0x0045) /* LATIN CAPITAL LETTER E */;
2047   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x46 - 33]
2048     = make_char (0x0046) /* LATIN CAPITAL LETTER F */;
2049   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x47 - 33]
2050     = make_char (0x0047) /* LATIN CAPITAL LETTER G */;
2051   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x48 - 33]
2052     = make_char (0x0048) /* LATIN CAPITAL LETTER H */;
2053   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x49 - 33]
2054     = make_char (0x0049) /* LATIN CAPITAL LETTER I */;
2055   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x4A - 33]
2056     = make_char (0x004A) /* LATIN CAPITAL LETTER J */;
2057   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x4B - 33]
2058     = make_char (0x004B) /* LATIN CAPITAL LETTER K */;
2059   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x4C - 33]
2060     = make_char (0x004C) /* LATIN CAPITAL LETTER L */;
2061   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x4D - 33]
2062     = make_char (0x004D) /* LATIN CAPITAL LETTER M */;
2063   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x4E - 33]
2064     = make_char (0x004E) /* LATIN CAPITAL LETTER N */;
2065   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x4F - 33]
2066     = make_char (0x004F) /* LATIN CAPITAL LETTER O */;
2067   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x50 - 33]
2068     = make_char (0x0050) /* LATIN CAPITAL LETTER P */;
2069   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x51 - 33]
2070     = make_char (0x0051) /* LATIN CAPITAL LETTER Q */;
2071   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x52 - 33]
2072     = make_char (0x0052) /* LATIN CAPITAL LETTER R */;
2073   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x53 - 33]
2074     = make_char (0x0053) /* LATIN CAPITAL LETTER S */;
2075   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x54 - 33]
2076     = make_char (0x0054) /* LATIN CAPITAL LETTER T */;
2077   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x55 - 33]
2078     = make_char (0x0055) /* LATIN CAPITAL LETTER U */;
2079   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x56 - 33]
2080     = make_char (0x0056) /* LATIN CAPITAL LETTER V */;
2081   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x57 - 33]
2082     = make_char (0x0057) /* LATIN CAPITAL LETTER W */;
2083   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x58 - 33]
2084     = make_char (0x0058) /* LATIN CAPITAL LETTER X */;
2085   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x59 - 33]
2086     = make_char (0x0059) /* LATIN CAPITAL LETTER Y */;
2087   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x5A - 33]
2088     = make_char (0x005A) /* LATIN CAPITAL LETTER Z */;
2089   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x5B - 33]
2090     = make_char (0x005B) /* LEFT SQUARE BRACKET */;
2091   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x5C - 33]
2092     = make_char (0x00A5) /* YEN SIGN */;
2093   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x5D - 33]
2094     = make_char (0x005D) /* RIGHT SQUARE BRACKET */;
2095   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x5E - 33]
2096     = make_char (0x005E) /* CIRCUMFLEX ACCENT */;
2097   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x5F - 33]
2098     = make_char (0x005F) /* LOW LINE */;
2099   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x60 - 33]
2100     = make_char (0x0060) /* GRAVE ACCENT */;
2101   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x61 - 33]
2102     = make_char (0x0061) /* LATIN SMALL LETTER A */;
2103   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x62 - 33]
2104     = make_char (0x0062) /* LATIN SMALL LETTER B */;
2105   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x63 - 33]
2106     = make_char (0x0063) /* LATIN SMALL LETTER C */;
2107   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x64 - 33]
2108     = make_char (0x0064) /* LATIN SMALL LETTER D */;
2109   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x65 - 33]
2110     = make_char (0x0065) /* LATIN SMALL LETTER E */;
2111   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x66 - 33]
2112     = make_char (0x0066) /* LATIN SMALL LETTER F */;
2113   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x67 - 33]
2114     = make_char (0x0067) /* LATIN SMALL LETTER G */;
2115   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x68 - 33]
2116     = make_char (0x0068) /* LATIN SMALL LETTER H */;
2117   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x69 - 33]
2118     = make_char (0x0069) /* LATIN SMALL LETTER I */;
2119   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x6A - 33]
2120     = make_char (0x006A) /* LATIN SMALL LETTER J */;
2121   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x6B - 33]
2122     = make_char (0x006B) /* LATIN SMALL LETTER K */;
2123   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x6C - 33]
2124     = make_char (0x006C) /* LATIN SMALL LETTER L */;
2125   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x6D - 33]
2126     = make_char (0x006D) /* LATIN SMALL LETTER M */;
2127   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x6E - 33]
2128     = make_char (0x006E) /* LATIN SMALL LETTER N */;
2129   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x6F - 33]
2130     = make_char (0x006F) /* LATIN SMALL LETTER O */;
2131   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x70 - 33]
2132     = make_char (0x0070) /* LATIN SMALL LETTER P */;
2133   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x71 - 33]
2134     = make_char (0x0071) /* LATIN SMALL LETTER Q */;
2135   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x72 - 33]
2136     = make_char (0x0072) /* LATIN SMALL LETTER R */;
2137   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x73 - 33]
2138     = make_char (0x0073) /* LATIN SMALL LETTER S */;
2139   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x74 - 33]
2140     = make_char (0x0074) /* LATIN SMALL LETTER T */;
2141   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x75 - 33]
2142     = make_char (0x0075) /* LATIN SMALL LETTER U */;
2143   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x76 - 33]
2144     = make_char (0x0076) /* LATIN SMALL LETTER V */;
2145   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x77 - 33]
2146     = make_char (0x0077) /* LATIN SMALL LETTER W */;
2147   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x78 - 33]
2148     = make_char (0x0078) /* LATIN SMALL LETTER X */;
2149   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x79 - 33]
2150     = make_char (0x0079) /* LATIN SMALL LETTER Y */;
2151   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x7A - 33]
2152     = make_char (0x007A) /* LATIN SMALL LETTER Z */;
2153   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x7B - 33]
2154     = make_char (0x007B) /* LEFT CURLY BRACKET */;
2155   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x7C - 33]
2156     = make_char (0x007C) /* VERTICAL LINE */;
2157   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x7D - 33]
2158     = make_char (0x007D) /* RIGHT CURLY BRACKET */;
2159   XVECTOR_DATA(latin_jisx0201_to_ucs)[0x7E - 33]
2160     = make_char (0x203E) /* OVERLINE */;
2161   
2162   staticpro (&latin_iso8859_2_to_ucs);
2163   latin_iso8859_2_to_ucs = make_vector (96, Qnil);
2164   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA0 - 0xA0]
2165     = make_char (0x00A0) /* NO-BREAK SPACE */;
2166   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA1 - 0xA0]
2167     = make_char (0x0104) /* LATIN CAPITAL LETTER A WITH OGONEK */;
2168   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA2 - 0xA0]
2169     = make_char (0x02D8) /* BREVE */;
2170   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA3 - 0xA0]
2171     = make_char (0x0141) /* LATIN CAPITAL LETTER L WITH STROKE */;
2172   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA4 - 0xA0]
2173     = make_char (0x00A4) /* CURRENCY SIGN */;
2174   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA5 - 0xA0]
2175     = make_char (0x013D) /* LATIN CAPITAL LETTER L WITH CARON */;
2176   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA6 - 0xA0]
2177     = make_char (0x015A) /* LATIN CAPITAL LETTER S WITH ACUTE */;
2178   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA7 - 0xA0]
2179     = make_char (0x00A7) /* SECTION SIGN */;
2180   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA8 - 0xA0]
2181     = make_char (0x00A8) /* DIAERESIS */;
2182   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xA9 - 0xA0]
2183     = make_char (0x0160) /* LATIN CAPITAL LETTER S WITH CARON */;
2184   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xAA - 0xA0]
2185     = make_char (0x015E) /* LATIN CAPITAL LETTER S WITH CEDILLA */;
2186   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xAB - 0xA0]
2187     = make_char (0x0164) /* LATIN CAPITAL LETTER T WITH CARON */;
2188   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xAC - 0xA0]
2189     = make_char (0x0179) /* LATIN CAPITAL LETTER Z WITH ACUTE */;
2190   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xAD - 0xA0]
2191     = make_char (0x00AD) /* SOFT HYPHEN */;
2192   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xAE - 0xA0]
2193     = make_char (0x017D) /* LATIN CAPITAL LETTER Z WITH CARON */;
2194   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xAF - 0xA0]
2195     = make_char (0x017B) /* LATIN CAPITAL LETTER Z WITH DOT ABOVE */;
2196   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB0 - 0xA0]
2197     = make_char (0x00B0) /* DEGREE SIGN */;
2198   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB1 - 0xA0]
2199     = make_char (0x0105) /* LATIN SMALL LETTER A WITH OGONEK */;
2200   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB2 - 0xA0]
2201     = make_char (0x02DB) /* OGONEK */;
2202   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB3 - 0xA0]
2203     = make_char (0x0142) /* LATIN SMALL LETTER L WITH STROKE */;
2204   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB4 - 0xA0]
2205     = make_char (0x00B4) /* ACUTE ACCENT */;
2206   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB5 - 0xA0]
2207     = make_char (0x013E) /* LATIN SMALL LETTER L WITH CARON */;
2208   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB6 - 0xA0]
2209     = make_char (0x015B) /* LATIN SMALL LETTER S WITH ACUTE */;
2210   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB7 - 0xA0]
2211     = make_char (0x02C7) /* CARON */;
2212   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB8 - 0xA0]
2213     = make_char (0x00B8) /* CEDILLA */;
2214   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xB9 - 0xA0]
2215     = make_char (0x0161) /* LATIN SMALL LETTER S WITH CARON */;
2216   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xBA - 0xA0]
2217     = make_char (0x015F) /* LATIN SMALL LETTER S WITH CEDILLA */;
2218   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xBB - 0xA0]
2219     = make_char (0x0165) /* LATIN SMALL LETTER T WITH CARON */;
2220   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xBC - 0xA0]
2221     = make_char (0x017A) /* LATIN SMALL LETTER Z WITH ACUTE */;
2222   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xBD - 0xA0]
2223     = make_char (0x02DD) /* DOUBLE ACUTE ACCENT */;
2224   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xBE - 0xA0]
2225     = make_char (0x017E) /* LATIN SMALL LETTER Z WITH CARON */;
2226   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xBF - 0xA0]
2227     = make_char (0x017C) /* LATIN SMALL LETTER Z WITH DOT ABOVE */;
2228   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC0 - 0xA0]
2229     = make_char (0x0154) /* LATIN CAPITAL LETTER R WITH ACUTE */;
2230   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC1 - 0xA0]
2231     = make_char (0x00C1) /* LATIN CAPITAL LETTER A WITH ACUTE */;
2232   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC2 - 0xA0]
2233     = make_char (0x00C2) /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */;
2234   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC3 - 0xA0]
2235     = make_char (0x0102) /* LATIN CAPITAL LETTER A WITH BREVE */;
2236   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC4 - 0xA0]
2237     = make_char (0x00C4) /* LATIN CAPITAL LETTER A WITH DIAERESIS */;
2238   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC5 - 0xA0]
2239     = make_char (0x0139) /* LATIN CAPITAL LETTER L WITH ACUTE */;
2240   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC6 - 0xA0]
2241     = make_char (0x0106) /* LATIN CAPITAL LETTER C WITH ACUTE */;
2242   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC7 - 0xA0]
2243     = make_char (0x00C7) /* LATIN CAPITAL LETTER C WITH CEDILLA */;
2244   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC8 - 0xA0]
2245     = make_char (0x010C) /* LATIN CAPITAL LETTER C WITH CARON */;
2246   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xC9 - 0xA0]
2247     = make_char (0x00C9) /* LATIN CAPITAL LETTER E WITH ACUTE */;
2248   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xCA - 0xA0]
2249     = make_char (0x0118) /* LATIN CAPITAL LETTER E WITH OGONEK */;
2250   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xCB - 0xA0]
2251     = make_char (0x00CB) /* LATIN CAPITAL LETTER E WITH DIAERESIS */;
2252   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xCC - 0xA0]
2253     = make_char (0x011A) /* LATIN CAPITAL LETTER E WITH CARON */;
2254   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xCD - 0xA0]
2255     = make_char (0x00CD) /* LATIN CAPITAL LETTER I WITH ACUTE */;
2256   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xCE - 0xA0]
2257     = make_char (0x00CE) /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */;
2258   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xCF - 0xA0]
2259     = make_char (0x010E) /* LATIN CAPITAL LETTER D WITH CARON */;
2260   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD0 - 0xA0]
2261     = make_char (0x0110) /* LATIN CAPITAL LETTER D WITH STROKE */;
2262   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD1 - 0xA0]
2263     = make_char (0x0143) /* LATIN CAPITAL LETTER N WITH ACUTE */;
2264   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD2 - 0xA0]
2265     = make_char (0x0147) /* LATIN CAPITAL LETTER N WITH CARON */;
2266   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD3 - 0xA0]
2267     = make_char (0x00D3) /* LATIN CAPITAL LETTER O WITH ACUTE */;
2268   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD4 - 0xA0]
2269     = make_char (0x00D4) /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */;
2270   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD5 - 0xA0]
2271     = make_char (0x0150) /* LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */;
2272   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD6 - 0xA0]
2273     = make_char (0x00D6) /* LATIN CAPITAL LETTER O WITH DIAERESIS */;
2274   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD7 - 0xA0]
2275     = make_char (0x00D7) /* MULTIPLICATION SIGN */;
2276   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD8 - 0xA0]
2277     = make_char (0x0158) /* LATIN CAPITAL LETTER R WITH CARON */;
2278   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xD9 - 0xA0]
2279     = make_char (0x016E) /* LATIN CAPITAL LETTER U WITH RING ABOVE */;
2280   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xDA - 0xA0]
2281     = make_char (0x00DA) /* LATIN CAPITAL LETTER U WITH ACUTE */;
2282   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xDB - 0xA0]
2283     = make_char (0x0170) /* LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */;
2284   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xDC - 0xA0]
2285     = make_char (0x00DC) /* LATIN CAPITAL LETTER U WITH DIAERESIS */;
2286   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xDD - 0xA0]
2287     = make_char (0x00DD) /* LATIN CAPITAL LETTER Y WITH ACUTE */;
2288   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xDE - 0xA0]
2289     = make_char (0x0162) /* LATIN CAPITAL LETTER T WITH CEDILLA */;
2290   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xDF - 0xA0]
2291     = make_char (0x00DF) /* LATIN SMALL LETTER SHARP S */;
2292   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE0 - 0xA0]
2293     = make_char (0x0155) /* LATIN SMALL LETTER R WITH ACUTE */;
2294   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE1 - 0xA0]
2295     = make_char (0x00E1) /* LATIN SMALL LETTER A WITH ACUTE */;
2296   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE2 - 0xA0]
2297     = make_char (0x00E2) /* LATIN SMALL LETTER A WITH CIRCUMFLEX */;
2298   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE3 - 0xA0]
2299     = make_char (0x0103) /* LATIN SMALL LETTER A WITH BREVE */;
2300   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE4 - 0xA0]
2301     = make_char (0x00E4) /* LATIN SMALL LETTER A WITH DIAERESIS */;
2302   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE5 - 0xA0]
2303     = make_char (0x013A) /* LATIN SMALL LETTER L WITH ACUTE */;
2304   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE6 - 0xA0]
2305     = make_char (0x0107) /* LATIN SMALL LETTER C WITH ACUTE */;
2306   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE7 - 0xA0]
2307     = make_char (0x00E7) /* LATIN SMALL LETTER C WITH CEDILLA */;
2308   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE8 - 0xA0]
2309     = make_char (0x010D) /* LATIN SMALL LETTER C WITH CARON */;
2310   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xE9 - 0xA0]
2311     = make_char (0x00E9) /* LATIN SMALL LETTER E WITH ACUTE */;
2312   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xEA - 0xA0]
2313     = make_char (0x0119) /* LATIN SMALL LETTER E WITH OGONEK */;
2314   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xEB - 0xA0]
2315     = make_char (0x00EB) /* LATIN SMALL LETTER E WITH DIAERESIS */;
2316   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xEC - 0xA0]
2317     = make_char (0x011B) /* LATIN SMALL LETTER E WITH CARON */;
2318   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xED - 0xA0]
2319     = make_char (0x00ED) /* LATIN SMALL LETTER I WITH ACUTE */;
2320   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xEE - 0xA0]
2321     = make_char (0x00EE) /* LATIN SMALL LETTER I WITH CIRCUMFLEX */;
2322   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xEF - 0xA0]
2323     = make_char (0x010F) /* LATIN SMALL LETTER D WITH CARON */;
2324   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF0 - 0xA0]
2325     = make_char (0x0111) /* LATIN SMALL LETTER D WITH STROKE */;
2326   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF1 - 0xA0]
2327     = make_char (0x0144) /* LATIN SMALL LETTER N WITH ACUTE */;
2328   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF2 - 0xA0]
2329     = make_char (0x0148) /* LATIN SMALL LETTER N WITH CARON */;
2330   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF3 - 0xA0]
2331     = make_char (0x00F3) /* LATIN SMALL LETTER O WITH ACUTE */;
2332   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF4 - 0xA0]
2333     = make_char (0x00F4) /* LATIN SMALL LETTER O WITH CIRCUMFLEX */;
2334   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF5 - 0xA0]
2335     = make_char (0x0151) /* LATIN SMALL LETTER O WITH DOUBLE ACUTE */;
2336   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF6 - 0xA0]
2337     = make_char (0x00F6) /* LATIN SMALL LETTER O WITH DIAERESIS */;
2338   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF7 - 0xA0]
2339     = make_char (0x00F7) /* DIVISION SIGN */;
2340   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF8 - 0xA0]
2341     = make_char (0x0159) /* LATIN SMALL LETTER R WITH CARON */;
2342   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xF9 - 0xA0]
2343     = make_char (0x016F) /* LATIN SMALL LETTER U WITH RING ABOVE */;
2344   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xFA - 0xA0]
2345     = make_char (0x00FA) /* LATIN SMALL LETTER U WITH ACUTE */;
2346   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xFB - 0xA0]
2347     = make_char (0x0171) /* LATIN SMALL LETTER U WITH DOUBLE ACUTE */;
2348   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xFC - 0xA0]
2349     = make_char (0x00FC) /* LATIN SMALL LETTER U WITH DIAERESIS */;
2350   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xFD - 0xA0]
2351     = make_char (0x00FD) /* LATIN SMALL LETTER Y WITH ACUTE */;
2352   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xFE - 0xA0]
2353     = make_char (0x0163) /* LATIN SMALL LETTER T WITH CEDILLA */;
2354   XVECTOR_DATA(latin_iso8859_2_to_ucs)[0xFF - 0xA0]
2355     = make_char (0x02D9) /* DOT ABOVE */;
2356   
2357   staticpro (&latin_iso8859_3_to_ucs);
2358   latin_iso8859_3_to_ucs = make_vector (96, Qnil);
2359   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA0 - 0xA0]
2360     = make_char (0x00A0) /* NO-BREAK SPACE */;
2361   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA1 - 0xA0]
2362     = make_char (0x0126) /* LATIN CAPITAL LETTER H WITH STROKE */;
2363   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA2 - 0xA0]
2364     = make_char (0x02D8) /* BREVE */;
2365   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA3 - 0xA0]
2366     = make_char (0x00A3) /* POUND SIGN */;
2367   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA4 - 0xA0]
2368     = make_char (0x00A4) /* CURRENCY SIGN */;
2369   /* XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA5 - 0xA0]
2370      = make_char (CHAR96('C', 0xA5));  */
2371   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA6 - 0xA0]
2372     = make_char (0x0124) /* LATIN CAPITAL LETTER H WITH CIRCUMFLEX */;
2373   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA7 - 0xA0]
2374     = make_char (0x00A7) /* SECTION SIGN */;
2375   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA8 - 0xA0]
2376     = make_char (0x00A8) /* DIAERESIS */;
2377   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xA9 - 0xA0]
2378     = make_char (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */;
2379   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xAA - 0xA0]
2380     = make_char (0x015E) /* LATIN CAPITAL LETTER S WITH CEDILLA */;
2381   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xAB - 0xA0]
2382     = make_char (0x011E) /* LATIN CAPITAL LETTER G WITH BREVE */;
2383   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xAC - 0xA0]
2384     = make_char (0x0134) /* LATIN CAPITAL LETTER J WITH CIRCUMFLEX */;
2385   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xAD - 0xA0]
2386     = make_char (0x00AD) /* SOFT HYPHEN */;
2387   /* XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xAE - 0xA0]
2388      = make_char (CHAR96('C', 0xAE)); */
2389   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xAF - 0xA0]
2390     = make_char (0x017B) /* LATIN CAPITAL LETTER Z WITH DOT ABOVE */;
2391   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB0 - 0xA0]
2392     = make_char (0x00B0) /* DEGREE SIGN */;
2393   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB1 - 0xA0]
2394     = make_char (0x0127) /* LATIN SMALL LETTER H WITH STROKE */;
2395   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB2 - 0xA0]
2396     = make_char (0x00B2) /* SUPERSCRIPT TWO */;
2397   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB3 - 0xA0]
2398     = make_char (0x00B3) /* SUPERSCRIPT THREE */;
2399   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB4 - 0xA0]
2400     = make_char (0x00B4) /* ACUTE ACCENT */;
2401   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB5 - 0xA0]
2402     = make_char (0x00B5) /* MICRO SIGN */;
2403   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB6 - 0xA0]
2404     = make_char (0x0125) /* LATIN SMALL LETTER H WITH CIRCUMFLEX */;
2405   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB7 - 0xA0]
2406     = make_char (0x00B7) /* MIDDLE DOT */;
2407   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB8 - 0xA0]
2408     = make_char (0x00B8) /* CEDILLA */;
2409   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xB9 - 0xA0]
2410     = make_char (0x0131) /* LATIN SMALL LETTER DOTLESS I */;
2411   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xBA - 0xA0]
2412     = make_char (0x015F) /* LATIN SMALL LETTER S WITH CEDILLA */;
2413   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xBB - 0xA0]
2414     = make_char (0x011F) /* LATIN SMALL LETTER G WITH BREVE */;
2415   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xBC - 0xA0]
2416     = make_char (0x0135) /* LATIN SMALL LETTER J WITH CIRCUMFLEX */;
2417   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xBD - 0xA0]
2418     = make_char (0x00BD) /* VULGAR FRACTION ONE HALF */;
2419   /* XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xBE - 0xA0]
2420      = make_char (CHAR96('C', 0xBE)); */
2421   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xBF - 0xA0]
2422     = make_char (0x017C) /* LATIN SMALL LETTER Z WITH DOT ABOVE */;
2423   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC0 - 0xA0]
2424     = make_char (0x00C0) /* LATIN CAPITAL LETTER A WITH GRAVE */;
2425   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC1 - 0xA0]
2426     = make_char (0x00C1) /* LATIN CAPITAL LETTER A WITH ACUTE */;
2427   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC2 - 0xA0]
2428     = make_char (0x00C2) /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */;
2429   /* XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC3 - 0xA0]
2430      = make_char (CHAR96('C', 0xC3)); */
2431   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC4 - 0xA0]
2432     = make_char (0x00C4) /* LATIN CAPITAL LETTER A WITH DIAERESIS */;
2433   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC5 - 0xA0]
2434     = make_char (0x010A) /* LATIN CAPITAL LETTER C WITH DOT ABOVE */;
2435   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC6 - 0xA0]
2436     = make_char (0x0108) /* LATIN CAPITAL LETTER C WITH CIRCUMFLEX */;
2437   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC7 - 0xA0]
2438     = make_char (0x00C7) /* LATIN CAPITAL LETTER C WITH CEDILLA */;
2439   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC8 - 0xA0]
2440     = make_char (0x00C8) /* LATIN CAPITAL LETTER E WITH GRAVE */;
2441   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xC9 - 0xA0]
2442     = make_char (0x00C9) /* LATIN CAPITAL LETTER E WITH ACUTE */;
2443   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xCA - 0xA0]
2444     = make_char (0x00CA) /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */;
2445   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xCB - 0xA0]
2446     = make_char (0x00CB) /* LATIN CAPITAL LETTER E WITH DIAERESIS */;
2447   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xCC - 0xA0]
2448     = make_char (0x00CC) /* LATIN CAPITAL LETTER I WITH GRAVE */;
2449   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xCD - 0xA0]
2450     = make_char (0x00CD) /* LATIN CAPITAL LETTER I WITH ACUTE */;
2451   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xCE - 0xA0]
2452     = make_char (0x00CE) /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */;
2453   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xCF - 0xA0]
2454     = make_char (0x00CF) /* LATIN CAPITAL LETTER I WITH DIAERESIS */;
2455   /* XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD0 - 0xA0]
2456      = make_char (CHAR96('C', 0xD0)); */
2457   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD1 - 0xA0]
2458     = make_char (0x00D1) /* LATIN CAPITAL LETTER N WITH TILDE */;
2459   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD2 - 0xA0]
2460     = make_char (0x00D2) /* LATIN CAPITAL LETTER O WITH GRAVE */;
2461   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD3 - 0xA0]
2462     = make_char (0x00D3) /* LATIN CAPITAL LETTER O WITH ACUTE */;
2463   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD4 - 0xA0]
2464     = make_char (0x00D4) /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */;
2465   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD5 - 0xA0]
2466     = make_char (0x0120) /* LATIN CAPITAL LETTER G WITH DOT ABOVE */;
2467   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD6 - 0xA0]
2468     = make_char (0x00D6) /* LATIN CAPITAL LETTER O WITH DIAERESIS */;
2469   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD7 - 0xA0]
2470     = make_char (0x00D7) /* MULTIPLICATION SIGN */;
2471   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD8 - 0xA0]
2472     = make_char (0x011C) /* LATIN CAPITAL LETTER G WITH CIRCUMFLEX */;
2473   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xD9 - 0xA0]
2474     = make_char (0x00D9) /* LATIN CAPITAL LETTER U WITH GRAVE */;
2475   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xDA - 0xA0]
2476     = make_char (0x00DA) /* LATIN CAPITAL LETTER U WITH ACUTE */;
2477   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xDB - 0xA0]
2478     = make_char (0x00DB) /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */;
2479   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xDC - 0xA0]
2480     = make_char (0x00DC) /* LATIN CAPITAL LETTER U WITH DIAERESIS */;
2481   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xDD - 0xA0]
2482     = make_char (0x016C) /* LATIN CAPITAL LETTER U WITH BREVE */;
2483   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xDE - 0xA0]
2484     = make_char (0x015C) /* LATIN CAPITAL LETTER S WITH CIRCUMFLEX */;
2485   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xDF - 0xA0]
2486     = make_char (0x00DF) /* LATIN SMALL LETTER SHARP S */;
2487   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE0 - 0xA0]
2488     = make_char (0x00E0) /* LATIN SMALL LETTER A WITH GRAVE */;
2489   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE1 - 0xA0]
2490     = make_char (0x00E1) /* LATIN SMALL LETTER A WITH ACUTE */;
2491   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE2 - 0xA0]
2492     = make_char (0x00E2) /* LATIN SMALL LETTER A WITH CIRCUMFLEX */;
2493   /* XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE3 - 0xA0]
2494      = make_char (CHAR96('C', 0xE3)); */
2495   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE4 - 0xA0]
2496     = make_char (0x00E4) /* LATIN SMALL LETTER A WITH DIAERESIS */;
2497   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE5 - 0xA0]
2498     = make_char (0x010B) /* LATIN SMALL LETTER C WITH DOT ABOVE */;
2499   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE6 - 0xA0]
2500     = make_char (0x0109) /* LATIN SMALL LETTER C WITH CIRCUMFLEX */;
2501   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE7 - 0xA0]
2502     = make_char (0x00E7) /* LATIN SMALL LETTER C WITH CEDILLA */;
2503   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE8 - 0xA0]
2504     = make_char (0x00E8) /* LATIN SMALL LETTER E WITH GRAVE */;
2505   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xE9 - 0xA0]
2506     = make_char (0x00E9) /* LATIN SMALL LETTER E WITH ACUTE */;
2507   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xEA - 0xA0]
2508     = make_char (0x00EA) /* LATIN SMALL LETTER E WITH CIRCUMFLEX */;
2509   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xEB - 0xA0]
2510     = make_char (0x00EB) /* LATIN SMALL LETTER E WITH DIAERESIS */;
2511   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xEC - 0xA0]
2512     = make_char (0x00EC) /* LATIN SMALL LETTER I WITH GRAVE */;
2513   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xED - 0xA0]
2514     = make_char (0x00ED) /* LATIN SMALL LETTER I WITH ACUTE */;
2515   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xEE - 0xA0]
2516     = make_char (0x00EE) /* LATIN SMALL LETTER I WITH CIRCUMFLEX */;
2517   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xEF - 0xA0]
2518     = make_char (0x00EF) /* LATIN SMALL LETTER I WITH DIAERESIS */;
2519   /* XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF0 - 0xA0]
2520      = make_char (CHAR96('C', 0xF0)); */
2521   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF1 - 0xA0]
2522     = make_char (0x00F1) /* LATIN SMALL LETTER N WITH TILDE */;
2523   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF2 - 0xA0]
2524     = make_char (0x00F2) /* LATIN SMALL LETTER O WITH GRAVE */;
2525   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF3 - 0xA0]
2526     = make_char (0x00F3) /* LATIN SMALL LETTER O WITH ACUTE */;
2527   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF4 - 0xA0]
2528     = make_char (0x00F4) /* LATIN SMALL LETTER O WITH CIRCUMFLEX */;
2529   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF5 - 0xA0]
2530     = make_char (0x0121) /* LATIN SMALL LETTER G WITH DOT ABOVE */;
2531   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF6 - 0xA0]
2532     = make_char (0x00F6) /* LATIN SMALL LETTER O WITH DIAERESIS */;
2533   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF7 - 0xA0]
2534     = make_char (0x00F7) /* DIVISION SIGN */;
2535   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF8 - 0xA0]
2536     = make_char (0x011D) /* LATIN SMALL LETTER G WITH CIRCUMFLEX */;
2537   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xF9 - 0xA0]
2538     = make_char (0x00F9) /* LATIN SMALL LETTER U WITH GRAVE */;
2539   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xFA - 0xA0]
2540     = make_char (0x00FA) /* LATIN SMALL LETTER U WITH ACUTE */;
2541   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xFB - 0xA0]
2542     = make_char (0x00FB) /* LATIN SMALL LETTER U WITH CIRCUMFLEX */;
2543   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xFC - 0xA0]
2544     = make_char (0x00FC) /* LATIN SMALL LETTER U WITH DIAERESIS */;
2545   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xFD - 0xA0]
2546     = make_char (0x016D) /* LATIN SMALL LETTER U WITH BREVE */;
2547   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xFE - 0xA0]
2548     = make_char (0x015D) /* LATIN SMALL LETTER S WITH CIRCUMFLEX */;
2549   XVECTOR_DATA(latin_iso8859_3_to_ucs)[0xFF - 0xA0]
2550     = make_char (0x02D9) /* DOT ABOVE */;
2551   
2552   staticpro (&latin_iso8859_4_to_ucs);
2553   latin_iso8859_4_to_ucs = make_vector (96, Qnil);
2554   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA0 - 0xA0]
2555     = make_char (0x00A0) /* NO-BREAK SPACE */;
2556   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA1 - 0xA0]
2557     = make_char (0x0104) /* LATIN CAPITAL LETTER A WITH OGONEK */;
2558   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA2 - 0xA0]
2559     = make_char (0x0138) /* LATIN SMALL LETTER KRA */;
2560   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA3 - 0xA0]
2561     = make_char (0x0156) /* LATIN CAPITAL LETTER R WITH CEDILLA */;
2562   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA4 - 0xA0]
2563     = make_char (0x00A4) /* CURRENCY SIGN */;
2564   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA5 - 0xA0]
2565     = make_char (0x0128) /* LATIN CAPITAL LETTER I WITH TILDE */;
2566   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA6 - 0xA0]
2567     = make_char (0x013B) /* LATIN CAPITAL LETTER L WITH CEDILLA */;
2568   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA7 - 0xA0]
2569     = make_char (0x00A7) /* SECTION SIGN */;
2570   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA8 - 0xA0]
2571     = make_char (0x00A8) /* DIAERESIS */;
2572   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xA9 - 0xA0]
2573     = make_char (0x0160) /* LATIN CAPITAL LETTER S WITH CARON */;
2574   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xAA - 0xA0]
2575     = make_char (0x0112) /* LATIN CAPITAL LETTER E WITH MACRON */;
2576   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xAB - 0xA0]
2577     = make_char (0x0122) /* LATIN CAPITAL LETTER G WITH CEDILLA */;
2578   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xAC - 0xA0]
2579     = make_char (0x0166) /* LATIN CAPITAL LETTER T WITH STROKE */;
2580   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xAD - 0xA0]
2581     = make_char (0x00AD) /* SOFT HYPHEN */;
2582   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xAE - 0xA0]
2583     = make_char (0x017D) /* LATIN CAPITAL LETTER Z WITH CARON */;
2584   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xAF - 0xA0]
2585     = make_char (0x00AF) /* MACRON */;
2586   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB0 - 0xA0]
2587     = make_char (0x00B0) /* DEGREE SIGN */;
2588   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB1 - 0xA0]
2589     = make_char (0x0105) /* LATIN SMALL LETTER A WITH OGONEK */;
2590   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB2 - 0xA0]
2591     = make_char (0x02DB) /* OGONEK */;
2592   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB3 - 0xA0]
2593     = make_char (0x0157) /* LATIN SMALL LETTER R WITH CEDILLA */;
2594   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB4 - 0xA0]
2595     = make_char (0x00B4) /* ACUTE ACCENT */;
2596   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB5 - 0xA0]
2597     = make_char (0x0129) /* LATIN SMALL LETTER I WITH TILDE */;
2598   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB6 - 0xA0]
2599     = make_char (0x013C) /* LATIN SMALL LETTER L WITH CEDILLA */;
2600   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB7 - 0xA0]
2601     = make_char (0x02C7) /* CARON */;
2602   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB8 - 0xA0]
2603     = make_char (0x00B8) /* CEDILLA */;
2604   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xB9 - 0xA0]
2605     = make_char (0x0161) /* LATIN SMALL LETTER S WITH CARON */;
2606   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xBA - 0xA0]
2607     = make_char (0x0113) /* LATIN SMALL LETTER E WITH MACRON */;
2608   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xBB - 0xA0]
2609     = make_char (0x0123) /* LATIN SMALL LETTER G WITH CEDILLA */;
2610   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xBC - 0xA0]
2611     = make_char (0x0167) /* LATIN SMALL LETTER T WITH STROKE */;
2612   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xBD - 0xA0]
2613     = make_char (0x014A) /* LATIN CAPITAL LETTER ENG */;
2614   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xBE - 0xA0]
2615     = make_char (0x017E) /* LATIN SMALL LETTER Z WITH CARON */;
2616   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xBF - 0xA0]
2617     = make_char (0x014B) /* LATIN SMALL LETTER ENG */;
2618   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC0 - 0xA0]
2619     = make_char (0x0100) /* LATIN CAPITAL LETTER A WITH MACRON */;
2620   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC1 - 0xA0]
2621     = make_char (0x00C1) /* LATIN CAPITAL LETTER A WITH ACUTE */;
2622   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC2 - 0xA0]
2623     = make_char (0x00C2) /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */;
2624   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC3 - 0xA0]
2625     = make_char (0x00C3) /* LATIN CAPITAL LETTER A WITH TILDE */;
2626   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC4 - 0xA0]
2627     = make_char (0x00C4) /* LATIN CAPITAL LETTER A WITH DIAERESIS */;
2628   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC5 - 0xA0]
2629     = make_char (0x00C5) /* LATIN CAPITAL LETTER A WITH RING ABOVE */;
2630   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC6 - 0xA0]
2631     = make_char (0x00C6) /* LATIN CAPITAL LETTER AE */;
2632   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC7 - 0xA0]
2633     = make_char (0x012E) /* LATIN CAPITAL LETTER I WITH OGONEK */;
2634   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC8 - 0xA0]
2635     = make_char (0x010C) /* LATIN CAPITAL LETTER C WITH CARON */;
2636   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xC9 - 0xA0]
2637     = make_char (0x00C9) /* LATIN CAPITAL LETTER E WITH ACUTE */;
2638   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xCA - 0xA0]
2639     = make_char (0x0118) /* LATIN CAPITAL LETTER E WITH OGONEK */;
2640   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xCB - 0xA0]
2641     = make_char (0x00CB) /* LATIN CAPITAL LETTER E WITH DIAERESIS */;
2642   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xCC - 0xA0]
2643     = make_char (0x0116) /* LATIN CAPITAL LETTER E WITH DOT ABOVE */;
2644   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xCD - 0xA0]
2645     = make_char (0x00CD) /* LATIN CAPITAL LETTER I WITH ACUTE */;
2646   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xCE - 0xA0]
2647     = make_char (0x00CE) /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */;
2648   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xCF - 0xA0]
2649     = make_char (0x012A) /* LATIN CAPITAL LETTER I WITH MACRON */;
2650   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD0 - 0xA0]
2651     = make_char (0x0110) /* LATIN CAPITAL LETTER D WITH STROKE */;
2652   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD1 - 0xA0]
2653     = make_char (0x0145) /* LATIN CAPITAL LETTER N WITH CEDILLA */;
2654   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD2 - 0xA0]
2655     = make_char (0x014C) /* LATIN CAPITAL LETTER O WITH MACRON */;
2656   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD3 - 0xA0]
2657     = make_char (0x0136) /* LATIN CAPITAL LETTER K WITH CEDILLA */;
2658   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD4 - 0xA0]
2659     = make_char (0x00D4) /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */;
2660   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD5 - 0xA0]
2661     = make_char (0x00D5) /* LATIN CAPITAL LETTER O WITH TILDE */;
2662   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD6 - 0xA0]
2663     = make_char (0x00D6) /* LATIN CAPITAL LETTER O WITH DIAERESIS */;
2664   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD7 - 0xA0]
2665     = make_char (0x00D7) /* MULTIPLICATION SIGN */;
2666   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD8 - 0xA0]
2667     = make_char (0x00D8) /* LATIN CAPITAL LETTER O WITH STROKE */;
2668   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xD9 - 0xA0]
2669     = make_char (0x0172) /* LATIN CAPITAL LETTER U WITH OGONEK */;
2670   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xDA - 0xA0]
2671     = make_char (0x00DA) /* LATIN CAPITAL LETTER U WITH ACUTE */;
2672   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xDB - 0xA0]
2673     = make_char (0x00DB) /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */;
2674   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xDC - 0xA0]
2675     = make_char (0x00DC) /* LATIN CAPITAL LETTER U WITH DIAERESIS */;
2676   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xDD - 0xA0]
2677     = make_char (0x0168) /* LATIN CAPITAL LETTER U WITH TILDE */;
2678   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xDE - 0xA0]
2679     = make_char (0x016A) /* LATIN CAPITAL LETTER U WITH MACRON */;
2680   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xDF - 0xA0]
2681     = make_char (0x00DF) /* LATIN SMALL LETTER SHARP S */;
2682   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE0 - 0xA0]
2683     = make_char (0x0101) /* LATIN SMALL LETTER A WITH MACRON */;
2684   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE1 - 0xA0]
2685     = make_char (0x00E1) /* LATIN SMALL LETTER A WITH ACUTE */;
2686   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE2 - 0xA0]
2687     = make_char (0x00E2) /* LATIN SMALL LETTER A WITH CIRCUMFLEX */;
2688   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE3 - 0xA0]
2689     = make_char (0x00E3) /* LATIN SMALL LETTER A WITH TILDE */;
2690   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE4 - 0xA0]
2691     = make_char (0x00E4) /* LATIN SMALL LETTER A WITH DIAERESIS */;
2692   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE5 - 0xA0]
2693     = make_char (0x00E5) /* LATIN SMALL LETTER A WITH RING ABOVE */;
2694   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE6 - 0xA0]
2695     = make_char (0x00E6) /* LATIN SMALL LETTER AE */;
2696   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE7 - 0xA0]
2697     = make_char (0x012F) /* LATIN SMALL LETTER I WITH OGONEK */;
2698   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE8 - 0xA0]
2699     = make_char (0x010D) /* LATIN SMALL LETTER C WITH CARON */;
2700   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xE9 - 0xA0]
2701     = make_char (0x00E9) /* LATIN SMALL LETTER E WITH ACUTE */;
2702   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xEA - 0xA0]
2703     = make_char (0x0119) /* LATIN SMALL LETTER E WITH OGONEK */;
2704   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xEB - 0xA0]
2705     = make_char (0x00EB) /* LATIN SMALL LETTER E WITH DIAERESIS */;
2706   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xEC - 0xA0]
2707     = make_char (0x0117) /* LATIN SMALL LETTER E WITH DOT ABOVE */;
2708   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xED - 0xA0]
2709     = make_char (0x00ED) /* LATIN SMALL LETTER I WITH ACUTE */;
2710   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xEE - 0xA0]
2711     = make_char (0x00EE) /* LATIN SMALL LETTER I WITH CIRCUMFLEX */;
2712   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xEF - 0xA0]
2713     = make_char (0x012B) /* LATIN SMALL LETTER I WITH MACRON */;
2714   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF0 - 0xA0]
2715     = make_char (0x0111) /* LATIN SMALL LETTER D WITH STROKE */;
2716   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF1 - 0xA0]
2717     = make_char (0x0146) /* LATIN SMALL LETTER N WITH CEDILLA */;
2718   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF2 - 0xA0]
2719     = make_char (0x014D) /* LATIN SMALL LETTER O WITH MACRON */;
2720   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF3 - 0xA0]
2721     = make_char (0x0137) /* LATIN SMALL LETTER K WITH CEDILLA */;
2722   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF4 - 0xA0]
2723     = make_char (0x00F4) /* LATIN SMALL LETTER O WITH CIRCUMFLEX */;
2724   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF5 - 0xA0]
2725     = make_char (0x00F5) /* LATIN SMALL LETTER O WITH TILDE */;
2726   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF6 - 0xA0]
2727     = make_char (0x00F6) /* LATIN SMALL LETTER O WITH DIAERESIS */;
2728   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF7 - 0xA0]
2729     = make_char (0x00F7) /* DIVISION SIGN */;
2730   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF8 - 0xA0]
2731     = make_char (0x00F8) /* LATIN SMALL LETTER O WITH STROKE */;
2732   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xF9 - 0xA0]
2733     = make_char (0x0173) /* LATIN SMALL LETTER U WITH OGONEK */;
2734   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xFA - 0xA0]
2735     = make_char (0x00FA) /* LATIN SMALL LETTER U WITH ACUTE */;
2736   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xFB - 0xA0]
2737     = make_char (0x00FB) /* LATIN SMALL LETTER U WITH CIRCUMFLEX */;
2738   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xFC - 0xA0]
2739     = make_char (0x00FC) /* LATIN SMALL LETTER U WITH DIAERESIS */;
2740   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xFD - 0xA0]
2741     = make_char (0x0169) /* LATIN SMALL LETTER U WITH TILDE */;
2742   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xFE - 0xA0]
2743     = make_char (0x016B) /* LATIN SMALL LETTER U WITH MACRON */;
2744   XVECTOR_DATA(latin_iso8859_4_to_ucs)[0xFF - 0xA0]
2745     = make_char (0x02D9) /* DOT ABOVE */;
2746   
2747   staticpro (&latin_iso8859_9_to_ucs);
2748   latin_iso8859_9_to_ucs = make_vector (96, Qnil);
2749   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA0 - 0xA0]
2750     = make_char (0x00A0) /* NO-BREAK SPACE */;
2751   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA1 - 0xA0]
2752     = make_char (0x00A1) /* INVERTED EXCLAMATION MARK */;
2753   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA2 - 0xA0]
2754     = make_char (0x00A2) /* CENT SIGN */;
2755   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA3 - 0xA0]
2756     = make_char (0x00A3) /* POUND SIGN */;
2757   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA4 - 0xA0]
2758     = make_char (0x00A4) /* CURRENCY SIGN */;
2759   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA5 - 0xA0]
2760     = make_char (0x00A5) /* YEN SIGN */;
2761   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA6 - 0xA0]
2762     = make_char (0x00A6) /* BROKEN BAR */;
2763   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA7 - 0xA0]
2764     = make_char (0x00A7) /* SECTION SIGN */;
2765   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA8 - 0xA0]
2766     = make_char (0x00A8) /* DIAERESIS */;
2767   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xA9 - 0xA0]
2768     = make_char (0x00A9) /* COPYRIGHT SIGN */;
2769   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xAA - 0xA0]
2770     = make_char (0x00AA) /* FEMININE ORDINAL INDICATOR */;
2771   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xAB - 0xA0]
2772     = make_char (0x00AB) /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */;
2773   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xAC - 0xA0]
2774     = make_char (0x00AC) /* NOT SIGN */;
2775   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xAD - 0xA0]
2776     = make_char (0x00AD) /* SOFT HYPHEN */;
2777   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xAE - 0xA0]
2778     = make_char (0x00AE) /* REGISTERED SIGN */;
2779   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xAF - 0xA0]
2780     = make_char (0x00AF) /* MACRON */;
2781   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB0 - 0xA0]
2782     = make_char (0x00B0) /* DEGREE SIGN */;
2783   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB1 - 0xA0]
2784     = make_char (0x00B1) /* PLUS-MINUS SIGN */;
2785   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB2 - 0xA0]
2786     = make_char (0x00B2) /* SUPERSCRIPT TWO */;
2787   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB3 - 0xA0]
2788     = make_char (0x00B3) /* SUPERSCRIPT THREE */;
2789   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB4 - 0xA0]
2790     = make_char (0x00B4) /* ACUTE ACCENT */;
2791   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB5 - 0xA0]
2792     = make_char (0x00B5) /* MICRO SIGN */;
2793   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB6 - 0xA0]
2794     = make_char (0x00B6) /* PILCROW SIGN */;
2795   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB7 - 0xA0]
2796     = make_char (0x00B7) /* MIDDLE DOT */;
2797   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB8 - 0xA0]
2798     = make_char (0x00B8) /* CEDILLA */;
2799   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xB9 - 0xA0]
2800     = make_char (0x00B9) /* SUPERSCRIPT ONE */;
2801   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xBA - 0xA0]
2802     = make_char (0x00BA) /* MASCULINE ORDINAL INDICATOR */;
2803   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xBB - 0xA0]
2804     = make_char (0x00BB) /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */;
2805   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xBC - 0xA0]
2806     = make_char (0x00BC) /* VULGAR FRACTION ONE QUARTER */;
2807   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xBD - 0xA0]
2808     = make_char (0x00BD) /* VULGAR FRACTION ONE HALF */;
2809   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xBE - 0xA0]
2810     = make_char (0x00BE) /* VULGAR FRACTION THREE QUARTERS */;
2811   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xBF - 0xA0]
2812     = make_char (0x00BF) /* INVERTED QUESTION MARK */;
2813   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC0 - 0xA0]
2814     = make_char (0x00C0) /* LATIN CAPITAL LETTER A WITH GRAVE */;
2815   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC1 - 0xA0]
2816     = make_char (0x00C1) /* LATIN CAPITAL LETTER A WITH ACUTE */;
2817   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC2 - 0xA0]
2818     = make_char (0x00C2) /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */;
2819   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC3 - 0xA0]
2820     = make_char (0x00C3) /* LATIN CAPITAL LETTER A WITH TILDE */;
2821   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC4 - 0xA0]
2822     = make_char (0x00C4) /* LATIN CAPITAL LETTER A WITH DIAERESIS */;
2823   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC5 - 0xA0]
2824     = make_char (0x00C5) /* LATIN CAPITAL LETTER A WITH RING ABOVE */;
2825   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC6 - 0xA0]
2826     = make_char (0x00C6) /* LATIN CAPITAL LETTER AE */;
2827   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC7 - 0xA0]
2828     = make_char (0x00C7) /* LATIN CAPITAL LETTER C WITH CEDILLA */;
2829   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC8 - 0xA0]
2830     = make_char (0x00C8) /* LATIN CAPITAL LETTER E WITH GRAVE */;
2831   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xC9 - 0xA0]
2832     = make_char (0x00C9) /* LATIN CAPITAL LETTER E WITH ACUTE */;
2833   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xCA - 0xA0]
2834     = make_char (0x00CA) /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */;
2835   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xCB - 0xA0]
2836     = make_char (0x00CB) /* LATIN CAPITAL LETTER E WITH DIAERESIS */;
2837   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xCC - 0xA0]
2838     = make_char (0x00CC) /* LATIN CAPITAL LETTER I WITH GRAVE */;
2839   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xCD - 0xA0]
2840     = make_char (0x00CD) /* LATIN CAPITAL LETTER I WITH ACUTE */;
2841   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xCE - 0xA0]
2842     = make_char (0x00CE) /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */;
2843   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xCF - 0xA0]
2844     = make_char (0x00CF) /* LATIN CAPITAL LETTER I WITH DIAERESIS */;
2845   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD0 - 0xA0]
2846     = make_char (0x011E) /* LATIN CAPITAL LETTER G WITH BREVE */;
2847   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD1 - 0xA0]
2848     = make_char (0x00D1) /* LATIN CAPITAL LETTER N WITH TILDE */;
2849   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD2 - 0xA0]
2850     = make_char (0x00D2) /* LATIN CAPITAL LETTER O WITH GRAVE */;
2851   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD3 - 0xA0]
2852     = make_char (0x00D3) /* LATIN CAPITAL LETTER O WITH ACUTE */;
2853   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD4 - 0xA0]
2854     = make_char (0x00D4) /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */;
2855   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD5 - 0xA0]
2856     = make_char (0x00D5) /* LATIN CAPITAL LETTER O WITH TILDE */;
2857   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD6 - 0xA0]
2858     = make_char (0x00D6) /* LATIN CAPITAL LETTER O WITH DIAERESIS */;
2859   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD7 - 0xA0]
2860     = make_char (0x00D7) /* MULTIPLICATION SIGN */;
2861   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD8 - 0xA0]
2862     = make_char (0x00D8) /* LATIN CAPITAL LETTER O WITH STROKE */;
2863   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xD9 - 0xA0]
2864     = make_char (0x00D9) /* LATIN CAPITAL LETTER U WITH GRAVE */;
2865   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xDA - 0xA0]
2866     = make_char (0x00DA) /* LATIN CAPITAL LETTER U WITH ACUTE */;
2867   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xDB - 0xA0]
2868     = make_char (0x00DB) /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */;
2869   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xDC - 0xA0]
2870     = make_char (0x00DC) /* LATIN CAPITAL LETTER U WITH DIAERESIS */;
2871   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xDD - 0xA0]
2872     = make_char (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */;
2873   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xDE - 0xA0]
2874     = make_char (0x015E) /* LATIN CAPITAL LETTER S WITH CEDILLA */;
2875   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xDF - 0xA0]
2876     = make_char (0x00DF) /* LATIN SMALL LETTER SHARP S */;
2877   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE0 - 0xA0]
2878     = make_char (0x00E0) /* LATIN SMALL LETTER A WITH GRAVE */;
2879   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE1 - 0xA0]
2880     = make_char (0x00E1) /* LATIN SMALL LETTER A WITH ACUTE */;
2881   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE2 - 0xA0]
2882     = make_char (0x00E2) /* LATIN SMALL LETTER A WITH CIRCUMFLEX */;
2883   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE3 - 0xA0]
2884     = make_char (0x00E3) /* LATIN SMALL LETTER A WITH TILDE */;
2885   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE4 - 0xA0]
2886     = make_char (0x00E4) /* LATIN SMALL LETTER A WITH DIAERESIS */;
2887   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE5 - 0xA0]
2888     = make_char (0x00E5) /* LATIN SMALL LETTER A WITH RING ABOVE */;
2889   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE6 - 0xA0]
2890     = make_char (0x00E6) /* LATIN SMALL LETTER AE */;
2891   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE7 - 0xA0]
2892     = make_char (0x00E7) /* LATIN SMALL LETTER C WITH CEDILLA */;
2893   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE8 - 0xA0]
2894     = make_char (0x00E8) /* LATIN SMALL LETTER E WITH GRAVE */;
2895   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xE9 - 0xA0]
2896     = make_char (0x00E9) /* LATIN SMALL LETTER E WITH ACUTE */;
2897   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xEA - 0xA0]
2898     = make_char (0x00EA) /* LATIN SMALL LETTER E WITH CIRCUMFLEX */;
2899   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xEB - 0xA0]
2900     = make_char (0x00EB) /* LATIN SMALL LETTER E WITH DIAERESIS */;
2901   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xEC - 0xA0]
2902     = make_char (0x00EC) /* LATIN SMALL LETTER I WITH GRAVE */;
2903   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xED - 0xA0]
2904     = make_char (0x00ED) /* LATIN SMALL LETTER I WITH ACUTE */;
2905   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xEE - 0xA0]
2906     = make_char (0x00EE) /* LATIN SMALL LETTER I WITH CIRCUMFLEX */;
2907   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xEF - 0xA0]
2908     = make_char (0x00EF) /* LATIN SMALL LETTER I WITH DIAERESIS */;
2909   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF0 - 0xA0]
2910     = make_char (0x011F) /* LATIN SMALL LETTER G WITH BREVE */;
2911   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF1 - 0xA0]
2912     = make_char (0x00F1) /* LATIN SMALL LETTER N WITH TILDE */;
2913   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF2 - 0xA0]
2914     = make_char (0x00F2) /* LATIN SMALL LETTER O WITH GRAVE */;
2915   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF3 - 0xA0]
2916     = make_char (0x00F3) /* LATIN SMALL LETTER O WITH ACUTE */;
2917   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF4 - 0xA0]
2918     = make_char (0x00F4) /* LATIN SMALL LETTER O WITH CIRCUMFLEX */;
2919   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF5 - 0xA0]
2920     = make_char (0x00F5) /* LATIN SMALL LETTER O WITH TILDE */;
2921   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF6 - 0xA0]
2922     = make_char (0x00F6) /* LATIN SMALL LETTER O WITH DIAERESIS */;
2923   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF7 - 0xA0]
2924     = make_char (0x00F7) /* DIVISION SIGN */;
2925   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF8 - 0xA0]
2926     = make_char (0x00F8) /* LATIN SMALL LETTER O WITH STROKE */;
2927   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xF9 - 0xA0]
2928     = make_char (0x00F9) /* LATIN SMALL LETTER U WITH GRAVE */;
2929   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xFA - 0xA0]
2930     = make_char (0x00FA) /* LATIN SMALL LETTER U WITH ACUTE */;
2931   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xFB - 0xA0]
2932     = make_char (0x00FB) /* LATIN SMALL LETTER U WITH CIRCUMFLEX */;
2933   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xFC - 0xA0]
2934     = make_char (0x00FC) /* LATIN SMALL LETTER U WITH DIAERESIS */;
2935   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xFD - 0xA0]
2936     = make_char (0x0131) /* LATIN SMALL LETTER DOTLESS I */;
2937   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xFE - 0xA0]
2938     = make_char (0x015F) /* LATIN SMALL LETTER S WITH CEDILLA */;
2939   XVECTOR_DATA(latin_iso8859_9_to_ucs)[0xFF - 0xA0]
2940     = make_char (0x00FF) /* LATIN SMALL LETTER Y WITH DIAERESIS */;
2941   
2942   staticpro (&latin_viscii_lower_to_ucs);
2943   latin_viscii_lower_to_ucs = make_vector (96, Qnil);
2944   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x20 - 32]
2945      = make_char (CHAR96('1', 0x20)); */
2946   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x21 - 32] = make_char (0x1eaf);
2947   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x22 - 32] = make_char (0x1eb1);
2948   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x23 - 32] = make_char (0x1eb7);
2949   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x24 - 32] = make_char (0x1ea5);
2950   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x25 - 32] = make_char (0x1ea7);
2951   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x26 - 32] = make_char (0x1ea9);
2952   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x27 - 32] = make_char (0x1ead);
2953   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x28 - 32] = make_char (0x1ebd);
2954   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x29 - 32] = make_char (0x1eb9);
2955   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x2a - 32] = make_char (0x1ebf);
2956   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x2b - 32] = make_char (0x1ec1);
2957   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x2c - 32] = make_char (0x1ec3);
2958   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x2d - 32] = make_char (0x1ec5);
2959   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x2e - 32] = make_char (0x1ec7);
2960   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x2f - 32] = make_char (0x1ed1);
2961   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x30 - 32] = make_char (0x1ed3);
2962   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x31 - 32] = make_char (0x1ed5);
2963   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x32 - 32] = make_char (0x1ed7);
2964   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x33 - 32]
2965      = make_char (CHAR96('1', 0x33)); */
2966   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x34 - 32]
2967      = make_char (CHAR96('1', 0x34)); */
2968   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x35 - 32] = make_char (0x1ed9);
2969   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x36 - 32] = make_char (0x1edd);
2970   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x37 - 32] = make_char (0x1edf);
2971   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x38 - 32] = make_char (0x1ecb);
2972   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x39 - 32]
2973      = make_char (CHAR96('1', 0x39));
2974      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x3A - 32]
2975      = make_char (CHAR96('1', 0x3A));
2976      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x3B - 32]
2977      = make_char (CHAR96('1', 0x3B));
2978      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x3C - 32]
2979      = make_char (CHAR96('1', 0x3C)); */
2980   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x3d - 32] = make_char (0x01a1);
2981   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x3e - 32] = make_char (0x1edb);
2982   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x3F - 32]
2983      = make_char (CHAR96('1', 0x3F));
2984      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x40 - 32]
2985      = make_char (CHAR96('1', 0x40));
2986      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x41 - 32]
2987      = make_char (CHAR96('1', 0x41));
2988      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x42 - 32]
2989      = make_char (CHAR96('1', 0x42));
2990      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x43 - 32]
2991      = make_char (CHAR96('1', 0x43));
2992      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x44 - 32]
2993      = make_char (CHAR96('1', 0x44));
2994      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x45 - 32]
2995      = make_char (CHAR96('1', 0x45)); */
2996   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x46 - 32] = make_char (0x1eb3);
2997   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x47 - 32] = make_char (0x1eb5);
2998   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x48 - 32]
2999      = make_char (CHAR96('1', 0x48));
3000      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x49 - 32]
3001      = make_char (CHAR96('1', 0x49));
3002      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x4A - 32]
3003      = make_char (CHAR96('1', 0x4A));
3004      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x4B - 32]
3005      = make_char (CHAR96('1', 0x4B));
3006      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x4C - 32]
3007      = make_char (CHAR96('1', 0x4C));
3008      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x4D - 32]
3009      = make_char (CHAR96('1', 0x4D));
3010      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x4E - 32]
3011      = make_char (CHAR96('1', 0x4E)); */
3012   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x4f - 32] = make_char (0x1ef3);
3013   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x50 - 32]
3014      = make_char (CHAR96('1', 0x50)); */
3015   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x51 - 32] = make_char (0x1ee9);
3016   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x52 - 32]
3017      = make_char (CHAR96('1', 0x52));
3018      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x53 - 32]
3019      = make_char (CHAR96('1', 0x53));
3020      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x54 - 32]
3021      = make_char (CHAR96('1', 0x54)); */
3022   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x55 - 32] = make_char (0x1ea1);
3023   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x56 - 32] = make_char (0x1ef7);
3024   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x57 - 32] = make_char (0x1eeb);
3025   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x58 - 32] = make_char (0x1eed);
3026   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x59 - 32]
3027      = make_char (CHAR96('1', 0x59));
3028      XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x5A - 32]
3029      = make_char (CHAR96('1', 0x5A)); */
3030   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x5b - 32] = make_char (0x1ef9);
3031   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x5c - 32] = make_char (0x1ef5);
3032   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x5D - 32]
3033      = make_char (CHAR96('1', 0x5D)); */
3034   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x5e - 32] = make_char (0x1ee1);
3035   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x5f - 32] = make_char (0x01b0);
3036   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x60 - 32] = make_char (0x00e0);
3037   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x61 - 32] = make_char (0x00e1);
3038   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x62 - 32] = make_char (0x00e2);
3039   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x63 - 32] = make_char (0x00e3);
3040   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x64 - 32] = make_char (0x1ea3);
3041   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x65 - 32] = make_char (0x0103);
3042   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x66 - 32] = make_char (0x1eef);
3043   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x67 - 32] = make_char (0x1eab);
3044   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x68 - 32] = make_char (0x00e8);
3045   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x69 - 32] = make_char (0x00e9);
3046   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x6a - 32] = make_char (0x00ea);
3047   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x6b - 32] = make_char (0x1ebb);
3048   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x6c - 32] = make_char (0x00ec);
3049   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x6d - 32] = make_char (0x00ed);
3050   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x6e - 32] = make_char (0x0129);
3051   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x6f - 32] = make_char (0x1ec9);
3052   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x70 - 32] = make_char (0x0111);
3053   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x71 - 32] = make_char (0x1ef1);
3054   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x72 - 32] = make_char (0x00f2);
3055   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x73 - 32] = make_char (0x00f3);
3056   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x74 - 32] = make_char (0x00f4);
3057   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x75 - 32] = make_char (0x00f5);
3058   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x76 - 32] = make_char (0x1ecf);
3059   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x77 - 32] = make_char (0x1ecd);
3060   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x78 - 32] = make_char (0x1ee5);
3061   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x79 - 32] = make_char (0x00f9);
3062   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x7a - 32] = make_char (0x00fa);
3063   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x7b - 32] = make_char (0x0169);
3064   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x7c - 32] = make_char (0x1ee7);
3065   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x7d - 32] = make_char (0x00fd);
3066   XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x7e - 32] = make_char (0x1ee3);
3067   /* XVECTOR_DATA(latin_viscii_lower_to_ucs)[0x7F - 32]
3068      = make_char (CHAR96('1', 0x7F)); */
3069
3070   staticpro (&latin_viscii_upper_to_ucs);
3071   latin_viscii_upper_to_ucs = make_vector (96, Qnil);
3072   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x20 - 32]
3073      = make_char (CHAR96('2', 0x20)); */
3074   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x21 - 32] = make_char (0x1eae);
3075   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x22 - 32] = make_char (0x1eb0);
3076   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x23 - 32] = make_char (0x1eb6);
3077   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x24 - 32] = make_char (0x1ea4);
3078   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x25 - 32] = make_char (0x1ea6);
3079   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x26 - 32] = make_char (0x1ea8);
3080   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x27 - 32] = make_char (0x1eac);
3081   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x28 - 32] = make_char (0x1ebc);
3082   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x29 - 32] = make_char (0x1eb8);
3083   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x2a - 32] = make_char (0x1ebe);
3084   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x2b - 32] = make_char (0x1ec0);
3085   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x2c - 32] = make_char (0x1ec2);
3086   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x2d - 32] = make_char (0x1ec4);
3087   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x2e - 32] = make_char (0x1ec6);
3088   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x2f - 32] = make_char (0x1ed0);
3089   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x30 - 32] = make_char (0x1ed2);
3090   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x31 - 32] = make_char (0x1ed4);
3091   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x32 - 32] = make_char (0x1ed6);
3092   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x33 - 32]
3093      = make_char (CHAR96('2', 0x33)); */
3094   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x34 - 32]
3095      = make_char (CHAR96('2', 0x34)); */
3096   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x35 - 32] = make_char (0x1ed8);
3097   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x36 - 32] = make_char (0x1edc);
3098   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x37 - 32] = make_char (0x1ede);
3099   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x38 - 32] = make_char (0x1eca);
3100   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x39 - 32]
3101      = make_char (CHAR96('2', 0x39));
3102      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x3a - 32]
3103      = make_char (CHAR96('2', 0x3a));
3104      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x3b - 32]
3105      = make_char (CHAR96('2', 0x3b));
3106      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x3c - 32]
3107      = make_char (CHAR96('2', 0x3c)); */
3108   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x3d - 32] = make_char (0x01a0);
3109   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x3e - 32] = make_char (0x1eda);
3110   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x3f - 32]
3111      = make_char (CHAR96('2', 0x3f));
3112      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x40 - 32]
3113      = make_char (CHAR96('2', 0x40));
3114      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x41 - 32]
3115      = make_char (CHAR96('2', 0x41));
3116      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x42 - 32]
3117      = make_char (CHAR96('2', 0x42));
3118      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x43 - 32]
3119      = make_char (CHAR96('2', 0x43));
3120      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x44 - 32]
3121      = make_char (CHAR96('2', 0x44));
3122      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x45 - 32]
3123      = make_char (CHAR96('2', 0x45)); */
3124   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x46 - 32] = make_char (0x1eb2);
3125   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x47 - 32] = make_char (0x1eb4);
3126   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x48 - 32]
3127      = make_char (CHAR96('2', 0x48));
3128      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x49 - 32]
3129      = make_char (CHAR96('2', 0x49));
3130      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x4a - 32]
3131      = make_char (CHAR96('2', 0x4a));
3132      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x4b - 32]
3133      = make_char (CHAR96('2', 0x4b));
3134      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x4c - 32]
3135      = make_char (CHAR96('2', 0x4c));
3136      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x4d - 32]
3137      = make_char (CHAR96('2', 0x4d));
3138      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x4e - 32]
3139      = make_char (CHAR96('2', 0x4e)); */
3140   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x4f - 32] = make_char (0x1ef2);
3141   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x50 - 32]
3142      = make_char (CHAR96('2', 0x50)); */
3143   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x51 - 32] = make_char (0x1ee8);
3144   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x52 - 32]
3145      = make_char (CHAR96('2', 0x52));
3146      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x53 - 32]
3147      = make_char (CHAR96('2', 0x53));
3148      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x54 - 32]
3149      = make_char (CHAR96('2', 0x54)); */
3150   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x55 - 32] = make_char (0x1ea0);
3151   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x56 - 32] = make_char (0x1ef6);
3152   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x57 - 32] = make_char (0x1eea);
3153   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x58 - 32] = make_char (0x1eec);
3154   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x59 - 32]
3155      = make_char (CHAR96('2', 0x59));
3156      XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x5a - 32]
3157      = make_char (CHAR96('2', 0x5a)); */
3158   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x5b - 32] = make_char (0x1ef8);
3159   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x5c - 32] = make_char (0x1ef4);
3160   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x5d - 32]
3161      = make_char (CHAR96('2', 0x5d)); */
3162   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x5e - 32] = make_char (0x1ee0);
3163   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x5f - 32] = make_char (0x01af);
3164   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x60 - 32] = make_char (0x00c0);
3165   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x61 - 32] = make_char (0x00c1);
3166   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x62 - 32] = make_char (0x00c2);
3167   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x63 - 32] = make_char (0x00c3);
3168   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x64 - 32] = make_char (0x1ea2);
3169   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x65 - 32] = make_char (0x0102);
3170   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x66 - 32] = make_char (0x1eee);
3171   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x67 - 32] = make_char (0x1eaa);
3172   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x68 - 32] = make_char (0x00c8);
3173   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x69 - 32] = make_char (0x00c9);
3174   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x6a - 32] = make_char (0x00ca);
3175   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x6b - 32] = make_char (0x1eba);
3176   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x6c - 32] = make_char (0x00cc);
3177   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x6d - 32] = make_char (0x00cd);
3178   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x6e - 32] = make_char (0x0128);
3179   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x6f - 32] = make_char (0x1ec8);
3180   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x70 - 32] = make_char (0x0110);
3181   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x71 - 32] = make_char (0x1ef0);
3182   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x72 - 32] = make_char (0x00d2);
3183   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x73 - 32] = make_char (0x00d3);
3184   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x74 - 32] = make_char (0x00d4);
3185   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x75 - 32] = make_char (0x00d5);
3186   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x76 - 32] = make_char (0x1ece);
3187   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x77 - 32] = make_char (0x1ecc);
3188   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x78 - 32] = make_char (0x1ee4);
3189   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x79 - 32] = make_char (0x00d9);
3190   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x7a - 32] = make_char (0x00da);
3191   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x7b - 32] = make_char (0x0168);
3192   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x7c - 32] = make_char (0x1ee6);
3193   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x7d - 32] = make_char (0x00dd);
3194   XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x7e - 32] = make_char (0x1ee2);
3195   /* XVECTOR_DATA(latin_viscii_upper_to_ucs)[0x7f - 32]
3196      = make_char (CHAR96('2', 0x7f)); */
3197
3198   Vcharset_ucs_bmp =
3199     make_charset (LEADING_BYTE_UCS_BMP, Qucs_bmp,
3200                   CHARSET_TYPE_256X256, 1, 0, 0,
3201                   CHARSET_LEFT_TO_RIGHT,
3202                   build_string ("BMP"),
3203                   build_string ("BMP"),
3204                   build_string ("BMP"),
3205                   build_string (""),
3206                   Qnil, 0, 0xFFFF, 0, 0);
3207 #else
3208 # define latin_iso8859_2_to_ucs NULL
3209 # define latin_iso8859_3_to_ucs NULL
3210 # define latin_iso8859_4_to_ucs NULL
3211 # define latin_iso8859_9_to_ucs NULL
3212 # define latin_jisx0201_to_ucs NULL
3213 # define MIN_CHAR_THAI 0
3214 # define MAX_CHAR_THAI 0
3215 # define MIN_CHAR_GREEK 0
3216 # define MAX_CHAR_GREEK 0
3217 # define MIN_CHAR_HEBREW 0
3218 # define MAX_CHAR_HEBREW 0
3219 # define MIN_CHAR_HALFWIDTH_KATAKANA 0
3220 # define MAX_CHAR_HALFWIDTH_KATAKANA 0
3221 # define MIN_CHAR_CYRILLIC 0
3222 # define MAX_CHAR_CYRILLIC 0
3223 #endif
3224   Vcharset_ascii =
3225     make_charset (LEADING_BYTE_ASCII, Qascii,
3226                   CHARSET_TYPE_94, 1, 0, 'B',
3227                   CHARSET_LEFT_TO_RIGHT,
3228                   build_string ("ASCII"),
3229                   build_string ("ASCII)"),
3230                   build_string ("ASCII (ISO646 IRV)"),
3231                   build_string ("\\(iso8859-[0-9]*\\|-ascii\\)"),
3232                   Qnil, 0, 0x7F, 0, 0);
3233   Vcharset_control_1 =
3234     make_charset (LEADING_BYTE_CONTROL_1, Qcontrol_1,
3235                   CHARSET_TYPE_94, 1, 1, 0,
3236                   CHARSET_LEFT_TO_RIGHT,
3237                   build_string ("C1"),
3238                   build_string ("Control characters"),
3239                   build_string ("Control characters 128-191"),
3240                   build_string (""),
3241                   Qnil, 0x80, 0x9F, 0, 0);
3242   Vcharset_latin_iso8859_1 =
3243     make_charset (LEADING_BYTE_LATIN_ISO8859_1, Qlatin_iso8859_1,
3244                   CHARSET_TYPE_96, 1, 1, 'A',
3245                   CHARSET_LEFT_TO_RIGHT,
3246                   build_string ("Latin-1"),
3247                   build_string ("ISO8859-1 (Latin-1)"),
3248                   build_string ("ISO8859-1 (Latin-1)"),
3249                   build_string ("iso8859-1"),
3250                   Qnil, 0xA0, 0xFF, 0, 32);
3251   Vcharset_latin_iso8859_2 =
3252     make_charset (LEADING_BYTE_LATIN_ISO8859_2, Qlatin_iso8859_2,
3253                   CHARSET_TYPE_96, 1, 1, 'B',
3254                   CHARSET_LEFT_TO_RIGHT,
3255                   build_string ("Latin-2"),
3256                   build_string ("ISO8859-2 (Latin-2)"),
3257                   build_string ("ISO8859-2 (Latin-2)"),
3258                   build_string ("iso8859-2"),
3259                   latin_iso8859_2_to_ucs, 0, 0, 0, 32);
3260   Vcharset_latin_iso8859_3 =
3261     make_charset (LEADING_BYTE_LATIN_ISO8859_3, Qlatin_iso8859_3,
3262                   CHARSET_TYPE_96, 1, 1, 'C',
3263                   CHARSET_LEFT_TO_RIGHT,
3264                   build_string ("Latin-3"),
3265                   build_string ("ISO8859-3 (Latin-3)"),
3266                   build_string ("ISO8859-3 (Latin-3)"),
3267                   build_string ("iso8859-3"),
3268                   latin_iso8859_3_to_ucs, 0, 0, 0, 32);
3269   Vcharset_latin_iso8859_4 =
3270     make_charset (LEADING_BYTE_LATIN_ISO8859_4, Qlatin_iso8859_4,
3271                   CHARSET_TYPE_96, 1, 1, 'D',
3272                   CHARSET_LEFT_TO_RIGHT,
3273                   build_string ("Latin-4"),
3274                   build_string ("ISO8859-4 (Latin-4)"),
3275                   build_string ("ISO8859-4 (Latin-4)"),
3276                   build_string ("iso8859-4"),
3277                   latin_iso8859_4_to_ucs, 0, 0, 0, 32);
3278   Vcharset_thai_tis620 =
3279     make_charset (LEADING_BYTE_THAI_TIS620, Qthai_tis620,
3280                   CHARSET_TYPE_96, 1, 1, 'T',
3281                   CHARSET_LEFT_TO_RIGHT,
3282                   build_string ("TIS620"),
3283                   build_string ("TIS620 (Thai)"),
3284                   build_string ("TIS620.2529 (Thai)"),
3285                   build_string ("tis620"),
3286                   Qnil, MIN_CHAR_THAI, MAX_CHAR_THAI, 0, 32);
3287   Vcharset_greek_iso8859_7 =
3288     make_charset (LEADING_BYTE_GREEK_ISO8859_7, Qgreek_iso8859_7,
3289                   CHARSET_TYPE_96, 1, 1, 'F',
3290                   CHARSET_LEFT_TO_RIGHT,
3291                   build_string ("ISO8859-7"),
3292                   build_string ("ISO8859-7 (Greek)"),
3293                   build_string ("ISO8859-7 (Greek)"),
3294                   build_string ("iso8859-7"),
3295                   Qnil, MIN_CHAR_GREEK, MAX_CHAR_GREEK, 0, 32);
3296   Vcharset_arabic_iso8859_6 =
3297     make_charset (LEADING_BYTE_ARABIC_ISO8859_6, Qarabic_iso8859_6,
3298                   CHARSET_TYPE_96, 1, 1, 'G',
3299                   CHARSET_RIGHT_TO_LEFT,
3300                   build_string ("ISO8859-6"),
3301                   build_string ("ISO8859-6 (Arabic)"),
3302                   build_string ("ISO8859-6 (Arabic)"),
3303                   build_string ("iso8859-6"),
3304                   Qnil, 0, 0, 0, 32);
3305   Vcharset_hebrew_iso8859_8 =
3306     make_charset (LEADING_BYTE_HEBREW_ISO8859_8, Qhebrew_iso8859_8,
3307                   CHARSET_TYPE_96, 1, 1, 'H',
3308                   CHARSET_RIGHT_TO_LEFT,
3309                   build_string ("ISO8859-8"),
3310                   build_string ("ISO8859-8 (Hebrew)"),
3311                   build_string ("ISO8859-8 (Hebrew)"),
3312                   build_string ("iso8859-8"),
3313                   Qnil, MIN_CHAR_HEBREW, MAX_CHAR_HEBREW, 0, 32);
3314   Vcharset_katakana_jisx0201 =
3315     make_charset (LEADING_BYTE_KATAKANA_JISX0201, Qkatakana_jisx0201,
3316                   CHARSET_TYPE_94, 1, 1, 'I',
3317                   CHARSET_LEFT_TO_RIGHT,
3318                   build_string ("JISX0201 Kana"),
3319                   build_string ("JISX0201.1976 (Japanese Kana)"),
3320                   build_string ("JISX0201.1976 Japanese Kana"),
3321                   build_string ("jisx0201\\.1976"),
3322                   Qnil,
3323                   MIN_CHAR_HALFWIDTH_KATAKANA,
3324                   MAX_CHAR_HALFWIDTH_KATAKANA, 0, 33);
3325   Vcharset_latin_jisx0201 =
3326     make_charset (LEADING_BYTE_LATIN_JISX0201, Qlatin_jisx0201,
3327                   CHARSET_TYPE_94, 1, 0, 'J',
3328                   CHARSET_LEFT_TO_RIGHT,
3329                   build_string ("JISX0201 Roman"),
3330                   build_string ("JISX0201.1976 (Japanese Roman)"),
3331                   build_string ("JISX0201.1976 Japanese Roman"),
3332                   build_string ("jisx0201\\.1976"),
3333                   latin_jisx0201_to_ucs, 0, 0, 0, 33);
3334   Vcharset_cyrillic_iso8859_5 =
3335     make_charset (LEADING_BYTE_CYRILLIC_ISO8859_5, Qcyrillic_iso8859_5,
3336                   CHARSET_TYPE_96, 1, 1, 'L',
3337                   CHARSET_LEFT_TO_RIGHT,
3338                   build_string ("ISO8859-5"),
3339                   build_string ("ISO8859-5 (Cyrillic)"),
3340                   build_string ("ISO8859-5 (Cyrillic)"),
3341                   build_string ("iso8859-5"),
3342                   Qnil, MIN_CHAR_CYRILLIC, MAX_CHAR_CYRILLIC, 0, 32);
3343   Vcharset_latin_iso8859_9 =
3344     make_charset (LEADING_BYTE_LATIN_ISO8859_9, Qlatin_iso8859_9,
3345                   CHARSET_TYPE_96, 1, 1, 'M',
3346                   CHARSET_LEFT_TO_RIGHT,
3347                   build_string ("Latin-5"),
3348                   build_string ("ISO8859-9 (Latin-5)"),
3349                   build_string ("ISO8859-9 (Latin-5)"),
3350                   build_string ("iso8859-9"),
3351                   latin_iso8859_9_to_ucs, 0, 0, 0, 32);
3352   Vcharset_japanese_jisx0208_1978 =
3353     make_charset (LEADING_BYTE_JAPANESE_JISX0208_1978, Qjapanese_jisx0208_1978,
3354                   CHARSET_TYPE_94X94, 2, 0, '@',
3355                   CHARSET_LEFT_TO_RIGHT,
3356                   build_string ("JIS X0208:1978"),
3357                   build_string ("JIS X0208:1978 (Japanese)"),
3358                   build_string
3359                   ("JIS X0208:1978 Japanese Kanji (so called \"old JIS\")"),
3360                   build_string ("\\(jisx0208\\|jisc6226\\)\\.1978"),
3361                   Qnil, 0, 0, 0, 33);
3362   Vcharset_chinese_gb2312 =
3363     make_charset (LEADING_BYTE_CHINESE_GB2312, Qchinese_gb2312,
3364                   CHARSET_TYPE_94X94, 2, 0, 'A',
3365                   CHARSET_LEFT_TO_RIGHT,
3366                   build_string ("GB2312"),
3367                   build_string ("GB2312)"),
3368                   build_string ("GB2312 Chinese simplified"),
3369                   build_string ("gb2312"),
3370                   Qnil, 0, 0, 0, 33);
3371   Vcharset_japanese_jisx0208 =
3372     make_charset (LEADING_BYTE_JAPANESE_JISX0208, Qjapanese_jisx0208,
3373                   CHARSET_TYPE_94X94, 2, 0, 'B',
3374                   CHARSET_LEFT_TO_RIGHT,
3375                   build_string ("JISX0208"),
3376                   build_string ("JIS X0208:1983 (Japanese)"),
3377                   build_string ("JIS X0208:1983 Japanese Kanji"),
3378                   build_string ("jisx0208\\.1983"),
3379                   Qnil, 0, 0, 0, 33);
3380   Vcharset_korean_ksc5601 =
3381     make_charset (LEADING_BYTE_KOREAN_KSC5601, Qkorean_ksc5601,
3382                   CHARSET_TYPE_94X94, 2, 0, 'C',
3383                   CHARSET_LEFT_TO_RIGHT,
3384                   build_string ("KSC5601"),
3385                   build_string ("KSC5601 (Korean"),
3386                   build_string ("KSC5601 Korean Hangul and Hanja"),
3387                   build_string ("ksc5601"),
3388                   Qnil, 0, 0, 0, 33);
3389   Vcharset_japanese_jisx0212 =
3390     make_charset (LEADING_BYTE_JAPANESE_JISX0212, Qjapanese_jisx0212,
3391                   CHARSET_TYPE_94X94, 2, 0, 'D',
3392                   CHARSET_LEFT_TO_RIGHT,
3393                   build_string ("JISX0212"),
3394                   build_string ("JISX0212 (Japanese)"),
3395                   build_string ("JISX0212 Japanese Supplement"),
3396                   build_string ("jisx0212"),
3397                   Qnil, 0, 0, 0, 33);
3398
3399 #define CHINESE_CNS_PLANE_RE(n) "cns11643[.-]\\(.*[.-]\\)?" n "$"
3400   Vcharset_chinese_cns11643_1 =
3401     make_charset (LEADING_BYTE_CHINESE_CNS11643_1, Qchinese_cns11643_1,
3402                   CHARSET_TYPE_94X94, 2, 0, 'G',
3403                   CHARSET_LEFT_TO_RIGHT,
3404                   build_string ("CNS11643-1"),
3405                   build_string ("CNS11643-1 (Chinese traditional)"),
3406                   build_string
3407                   ("CNS 11643 Plane 1 Chinese traditional"),
3408                   build_string (CHINESE_CNS_PLANE_RE("1")),
3409                   Qnil, 0, 0, 0, 33);
3410   Vcharset_chinese_cns11643_2 =
3411     make_charset (LEADING_BYTE_CHINESE_CNS11643_2, Qchinese_cns11643_2,
3412                   CHARSET_TYPE_94X94, 2, 0, 'H',
3413                   CHARSET_LEFT_TO_RIGHT,
3414                   build_string ("CNS11643-2"),
3415                   build_string ("CNS11643-2 (Chinese traditional)"),
3416                   build_string
3417                   ("CNS 11643 Plane 2 Chinese traditional"),
3418                   build_string (CHINESE_CNS_PLANE_RE("2")),
3419                   Qnil, 0, 0, 0, 33);
3420 #ifdef UTF2000
3421   Vcharset_latin_viscii_lower =
3422     make_charset (LEADING_BYTE_LATIN_VISCII_LOWER, Qlatin_viscii_lower,
3423                   CHARSET_TYPE_96, 1, 1, '1',
3424                   CHARSET_LEFT_TO_RIGHT,
3425                   build_string ("VISCII lower"),
3426                   build_string ("VISCII lower (Vietnamese)"),
3427                   build_string ("VISCII lower (Vietnamese)"),
3428                   build_string ("VISCII1\\.1"),
3429                   latin_viscii_lower_to_ucs, 0, 0, 0, 32);
3430   Vcharset_latin_viscii_upper =
3431     make_charset (LEADING_BYTE_LATIN_VISCII_UPPER, Qlatin_viscii_upper,
3432                   CHARSET_TYPE_96, 1, 1, '2',
3433                   CHARSET_LEFT_TO_RIGHT,
3434                   build_string ("VISCII upper"),
3435                   build_string ("VISCII upper (Vietnamese)"),
3436                   build_string ("VISCII upper (Vietnamese)"),
3437                   build_string ("VISCII1\\.1"),
3438                   latin_viscii_upper_to_ucs, 0, 0, 0, 32);
3439   Vcharset_hiragana_jisx0208 =
3440     make_charset (LEADING_BYTE_HIRAGANA_JISX0208, Qhiragana_jisx0208,
3441                   CHARSET_TYPE_94X94, 2, 0, 'B',
3442                   CHARSET_LEFT_TO_RIGHT,
3443                   build_string ("Hiragana"),
3444                   build_string ("Hiragana of JIS X0208"),
3445                   build_string ("Japanese Hiragana of JIS X0208"),
3446                   build_string ("jisx0208\\.19\\(78\\|83\\|90\\)"),
3447                   Qnil, MIN_CHAR_HIRAGANA, MAX_CHAR_HIRAGANA,
3448                   (0x24 - 33) * 94 + (0x21 - 33), 33);
3449   Vcharset_katakana_jisx0208 =
3450     make_charset (LEADING_BYTE_KATAKANA_JISX0208, Qkatakana_jisx0208,
3451                   CHARSET_TYPE_94X94, 2, 0, 'B',
3452                   CHARSET_LEFT_TO_RIGHT,
3453                   build_string ("Katakana"),
3454                   build_string ("Katakana of JIS X0208"),
3455                   build_string ("Japanese Katakana of JIS X0208"),
3456                   build_string ("jisx0208\\.19\\(78\\|83\\|90\\)"),
3457                   Qnil, MIN_CHAR_KATAKANA, MAX_CHAR_KATAKANA,
3458                   (0x25 - 33) * 94 + (0x21 - 33), 33);
3459 #endif
3460   Vcharset_chinese_big5_1 =
3461     make_charset (LEADING_BYTE_CHINESE_BIG5_1, Qchinese_big5_1,
3462                   CHARSET_TYPE_94X94, 2, 0, '0',
3463                   CHARSET_LEFT_TO_RIGHT,
3464                   build_string ("Big5"),
3465                   build_string ("Big5 (Level-1)"),
3466                   build_string
3467                   ("Big5 Level-1 Chinese traditional"),
3468                   build_string ("big5"),
3469                   Qnil, 0, 0, 0, 33);
3470   Vcharset_chinese_big5_2 =
3471     make_charset (LEADING_BYTE_CHINESE_BIG5_2, Qchinese_big5_2,
3472                   CHARSET_TYPE_94X94, 2, 0, '1',
3473                   CHARSET_LEFT_TO_RIGHT,
3474                   build_string ("Big5"),
3475                   build_string ("Big5 (Level-2)"),
3476                   build_string
3477                   ("Big5 Level-2 Chinese traditional"),
3478                   build_string ("big5"),
3479                   Qnil, 0, 0, 0, 33);
3480
3481 #ifdef ENABLE_COMPOSITE_CHARS
3482   /* #### For simplicity, we put composite chars into a 96x96 charset.
3483      This is going to lead to problems because you can run out of
3484      room, esp. as we don't yet recycle numbers. */
3485   Vcharset_composite =
3486     make_charset (LEADING_BYTE_COMPOSITE, Qcomposite,
3487                   CHARSET_TYPE_96X96, 2, 0, 0,
3488                   CHARSET_LEFT_TO_RIGHT,
3489                   build_string ("Composite"),
3490                   build_string ("Composite characters"),
3491                   build_string ("Composite characters"),
3492                   build_string (""));
3493
3494   composite_char_row_next = 32;
3495   composite_char_col_next = 32;
3496
3497   Vcomposite_char_string2char_hash_table =
3498     make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
3499   Vcomposite_char_char2string_hash_table =
3500     make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
3501   staticpro (&Vcomposite_char_string2char_hash_table);
3502   staticpro (&Vcomposite_char_char2string_hash_table);
3503 #endif /* ENABLE_COMPOSITE_CHARS */
3504
3505 }