beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luafontloader / fontforge / fontforge / macenc.c
blob7dd59529e7f4a5dd47c58f4b2bb2e58740ee0eb7
1 /* Copyright (C) 2003-2008 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include "fontforgevw.h"
28 #include <ustring.h>
29 #include "ttf.h"
32 The original data for these mappings may be found at
33 http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/
34 unfortunately this site does not contain all the macintosh encodings
35 so we leave some blank
37 /* Response (indirectly) from charsets@apple.com when asked about the missing
38 encodings:
40 > I don't believe any of those additional scripts are actually
41 > defined as character encodings. He can safely ignore anything
42 > that's not in the Apple folder on the Unicode site.
44 > I monitor charsets@apple.com and don't recall seeing any e-mail
45 > on this subject. It's possible it got lost in the voluminous
46 > spam the address receives.
48 > Deborah
49 I find this perplexing (unless the script is defined but unused, how can
50 it fail to have a defined encoding), but will accept it.
53 /* Macintosh 1 byte encodings */
54 static unichar_t arabic[256] = {
55 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
56 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
57 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
58 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
59 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
60 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
61 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
62 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
63 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
64 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
65 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
66 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
67 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
68 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
69 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
70 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
71 0x00c4, 0x00a0, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1,
72 0x00e0, 0x00e2, 0x00e4, 0x06ba, 0x00ab, 0x00e7, 0x00e9, 0x00e8,
73 0x00ea, 0x00eb, 0x00ed, 0x2026, 0x00ee, 0x00ef, 0x00f1, 0x00f3,
74 0x00bb, 0x00f4, 0x00f6, 0x00f7, 0x00fa, 0x00f9, 0x00fb, 0x00fc,
75 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x066a, 0x0026, 0x0027,
76 0x0028, 0x0029, 0x002a, 0x002b, 0x060c, 0x002d, 0x002e, 0x002f,
77 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667,
78 0x0668, 0x0669, 0x003a, 0x061b, 0x003c, 0x003d, 0x003e, 0x061f,
79 0x274a, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
80 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
81 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637,
82 0x0638, 0x0639, 0x063a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
83 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647,
84 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f,
85 0x0650, 0x0651, 0x0652, 0x067e, 0x0679, 0x0686, 0x06d5, 0x06a4,
86 0x06af, 0x0688, 0x0691, 0x007b, 0x007c, 0x007d, 0x0698, 0x06d2
89 static unichar_t centeuro[256] = {
90 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
91 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
92 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
93 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
94 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
95 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
96 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
97 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
98 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
99 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
100 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
101 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
102 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
103 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
104 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
105 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
106 0x00c4, 0x0100, 0x0101, 0x00c9, 0x0104, 0x00d6, 0x00dc, 0x00e1,
107 0x0105, 0x010c, 0x00e4, 0x010d, 0x0106, 0x0107, 0x00e9, 0x0179,
108 0x017a, 0x010e, 0x00ed, 0x010f, 0x0112, 0x0113, 0x0116, 0x00f3,
109 0x0117, 0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x011a, 0x011b, 0x00fc,
110 0x2020, 0x00b0, 0x0118, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df,
111 0x00ae, 0x00a9, 0x2122, 0x0119, 0x00a8, 0x2260, 0x0123, 0x012e,
112 0x012f, 0x012a, 0x2264, 0x2265, 0x012b, 0x0136, 0x2202, 0x2211,
113 0x0142, 0x013b, 0x013c, 0x013d, 0x013e, 0x0139, 0x013a, 0x0145,
114 0x0146, 0x0143, 0x00ac, 0x221a, 0x0144, 0x0147, 0x2206, 0x00ab,
115 0x00bb, 0x2026, 0x00a0, 0x0148, 0x0150, 0x00d5, 0x0151, 0x014c,
116 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca,
117 0x014d, 0x0154, 0x0155, 0x0158, 0x2039, 0x203a, 0x0159, 0x0156,
118 0x0157, 0x0160, 0x201a, 0x201e, 0x0161, 0x015a, 0x015b, 0x00c1,
119 0x0164, 0x0165, 0x00cd, 0x017d, 0x017e, 0x016a, 0x00d3, 0x00d4,
120 0x016b, 0x016e, 0x00da, 0x016f, 0x0170, 0x0171, 0x0172, 0x0173,
121 0x00dd, 0x00fd, 0x0137, 0x017b, 0x0141, 0x017c, 0x0122, 0x02c7
124 static unichar_t croatian[256] = {
125 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
126 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
127 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
128 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
129 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
130 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
131 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
132 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
133 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
134 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
135 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
136 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
137 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
138 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
139 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
140 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
141 0x00c4, 0x00c5, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1,
142 0x00e0, 0x00e2, 0x00e4, 0x00e3, 0x00e5, 0x00e7, 0x00e9, 0x00e8,
143 0x00ea, 0x00eb, 0x00ed, 0x00ec, 0x00ee, 0x00ef, 0x00f1, 0x00f3,
144 0x00f2, 0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x00f9, 0x00fb, 0x00fc,
145 0x2020, 0x00b0, 0x00a2, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df,
146 0x00ae, 0x0160, 0x2122, 0x00b4, 0x00a8, 0x2260, 0x017d, 0x00d8,
147 0x221e, 0x00b1, 0x2264, 0x2265, 0x2206, 0x00b5, 0x2202, 0x2211,
148 0x220f, 0x0161, 0x222b, 0x00aa, 0x00ba, 0x03a9, 0x017e, 0x00f8,
149 0x00bf, 0x00a1, 0x00ac, 0x221a, 0x0192, 0x2248, 0x0106, 0x00ab,
150 0x010c, 0x2026, 0x00a0, 0x00c0, 0x00c3, 0x00d5, 0x0152, 0x0153,
151 0x0110, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca,
152 0xf8ff, 0x00a9, 0x2044, 0x20ac, 0x2039, 0x203a, 0x00c6, 0x00bb,
153 0x2013, 0x00b7, 0x201a, 0x201e, 0x2030, 0x00c2, 0x0107, 0x00c1,
154 0x010d, 0x00c8, 0x00cd, 0x00ce, 0x00cf, 0x00cc, 0x00d3, 0x00d4,
155 0x0111, 0x00d2, 0x00da, 0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc,
156 0x00af, 0x03c0, 0x00cb, 0x02da, 0x00b8, 0x00ca, 0x00e6, 0x02c7
159 static unichar_t cyrillic[256] = {
160 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
161 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
162 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
163 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
164 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
165 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
166 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
167 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
168 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
169 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
170 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
171 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
172 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
173 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
174 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
175 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
176 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
177 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
178 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
179 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
180 0x2020, 0x00b0, 0x0490, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x0406,
181 0x00ae, 0x00a9, 0x2122, 0x0402, 0x0452, 0x2260, 0x0403, 0x0453,
182 0x221e, 0x00b1, 0x2264, 0x2265, 0x0456, 0x00b5, 0x0491, 0x0408,
183 0x0404, 0x0454, 0x0407, 0x0457, 0x0409, 0x0459, 0x040a, 0x045a,
184 0x0458, 0x0405, 0x00ac, 0x221a, 0x0192, 0x2248, 0x2206, 0x00ab,
185 0x00bb, 0x2026, 0x00a0, 0x040b, 0x045b, 0x040c, 0x045c, 0x0455,
186 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x201e,
187 0x040e, 0x045e, 0x040f, 0x045f, 0x2116, 0x0401, 0x0451, 0x044f,
188 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
189 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
190 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
191 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x20ac
194 static unichar_t devanagari[256] = {
195 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
196 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
197 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
198 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
199 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
200 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
201 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
202 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
203 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
204 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
205 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
206 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
207 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
208 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
209 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
210 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
211 0x00d7, 0x2212, 0x2013, 0x2014, 0x2018, 0x2019, 0x2026, 0x2022,
212 0x00a9, 0x00ae, 0x2122, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
213 0x0965, 0x0970, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
214 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
215 0x00a0, 0x0901, 0x0902, 0x0903, 0x0905, 0x0906, 0x0907, 0x0908,
216 0x0909, 0x090a, 0x090b, 0x090e, 0x090f, 0x0910, 0x090d, 0x0912,
217 0x0913, 0x0914, 0x0911, 0x0915, 0x0916, 0x0917, 0x0918, 0x0919,
218 0x091a, 0x091b, 0x091c, 0x091d, 0x091e, 0x091f, 0x0920, 0x0921,
219 0x0922, 0x0923, 0x0924, 0x0925, 0x0926, 0x0927, 0x0928, 0x0929,
220 0x092a, 0x092b, 0x092c, 0x092d, 0x092e, 0x092f, 0x095f, 0x0930,
221 0x0931, 0x0932, 0x0933, 0x0934, 0x0935, 0x0936, 0x0937, 0x0938,
222 0x0939, 0x200e, 0x093e, 0x093f, 0x0940, 0x0941, 0x0942, 0x0943,
223 0x0946, 0x0947, 0x0948, 0x0945, 0x094a, 0x094b, 0x094c, 0x0949,
224 0x094d, 0x093c, 0x0964, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
225 0x00f0, 0x0966, 0x0967, 0x0968, 0x0969, 0x096a, 0x096b, 0x096c,
226 0x096d, 0x096e, 0x096f,
229 static unichar_t farsi[256] = {
230 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
231 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
232 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
233 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
234 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
235 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
236 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
237 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
238 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
239 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
240 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
241 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
242 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
243 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
244 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
245 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
246 0x00c4, 0x00a0, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1,
247 0x00e0, 0x00e2, 0x00e4, 0x06ba, 0x00ab, 0x00e7, 0x00e9, 0x00e8,
248 0x00ea, 0x00eb, 0x00ed, 0x2026, 0x00ee, 0x00ef, 0x00f1, 0x00f3,
249 0x00bb, 0x00f4, 0x00f6, 0x00f7, 0x00fa, 0x00f9, 0x00fb, 0x00fc,
250 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x066a, 0x0026, 0x0027,
251 0x0028, 0x0029, 0x002a, 0x002b, 0x060c, 0x002d, 0x002e, 0x002f,
252 0x06f0, 0x06f1, 0x06f2, 0x06f3, 0x06f4, 0x06f5, 0x06f6, 0x06f7,
253 0x06f8, 0x06f9, 0x003a, 0x061b, 0x003c, 0x003d, 0x003e, 0x061f,
254 0x274a, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
255 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
256 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637,
257 0x0638, 0x0639, 0x063a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
258 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647,
259 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f,
260 0x0650, 0x0651, 0x0652, 0x067e, 0x0679, 0x0686, 0x06d5, 0x06a4,
261 0x06af, 0x0688, 0x0691, 0x007b, 0x007c, 0x007d, 0x0698, 0x06d2
264 static unichar_t greek[256] = {
265 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
266 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
267 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
268 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
269 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
270 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
271 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
272 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
273 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
274 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
275 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
276 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
277 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
278 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
279 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
280 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
281 0x00c4, 0x00b9, 0x00b2, 0x00c9, 0x00b3, 0x00d6, 0x00dc, 0x0385,
282 0x00e0, 0x00e2, 0x00e4, 0x0384, 0x00a8, 0x00e7, 0x00e9, 0x00e8,
283 0x00ea, 0x00eb, 0x00a3, 0x2122, 0x00ee, 0x00ef, 0x2022, 0x00bd,
284 0x2030, 0x00f4, 0x00f6, 0x00a6, 0x20ac, 0x00f9, 0x00fb, 0x00fc,
285 0x2020, 0x0393, 0x0394, 0x0398, 0x039b, 0x039e, 0x03a0, 0x00df,
286 0x00ae, 0x00a9, 0x03a3, 0x03aa, 0x00a7, 0x2260, 0x00b0, 0x00b7,
287 0x0391, 0x00b1, 0x2264, 0x2265, 0x00a5, 0x0392, 0x0395, 0x0396,
288 0x0397, 0x0399, 0x039a, 0x039c, 0x03a6, 0x03ab, 0x03a8, 0x03a9,
289 0x03ac, 0x039d, 0x00ac, 0x039f, 0x03a1, 0x2248, 0x03a4, 0x00ab,
290 0x00bb, 0x2026, 0x00a0, 0x03a5, 0x03a7, 0x0386, 0x0388, 0x0153,
291 0x2013, 0x2015, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x0389,
292 0x038a, 0x038c, 0x038e, 0x03ad, 0x03ae, 0x03af, 0x03cc, 0x038f,
293 0x03cd, 0x03b1, 0x03b2, 0x03c8, 0x03b4, 0x03b5, 0x03c6, 0x03b3,
294 0x03b7, 0x03b9, 0x03be, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03bf,
295 0x03c0, 0x03ce, 0x03c1, 0x03c3, 0x03c4, 0x03b8, 0x03c9, 0x03c2,
296 0x03c7, 0x03c5, 0x03b6, 0x03ca, 0x03cb, 0x0390, 0x03b0, 0x00ad
299 static unichar_t gujarati[256] = {
300 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
301 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
302 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
303 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
304 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
305 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
306 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
307 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
308 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
309 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
310 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
311 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
312 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
313 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
314 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
315 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
316 0x00d7, 0x2212, 0x2013, 0x2014, 0x2018, 0x2019, 0x2026, 0x2022,
317 0x00a9, 0x00ae, 0x2122, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
318 0x0965, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
319 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
320 0x00a0, 0x0a81, 0x0a82, 0x0a83, 0x0a85, 0x0a86, 0x0a87, 0x0a88,
321 0x0a89, 0x0a8a, 0x0a8b, 0x00ab, 0x0a8f, 0x0a90, 0x0a8d, 0x00af,
322 0x0a93, 0x0a94, 0x0a91, 0x0a95, 0x0a96, 0x0a97, 0x0a98, 0x0a99,
323 0x0a9a, 0x0a9b, 0x0a9c, 0x0a9d, 0x0a9e, 0x0a9f, 0x0aa0, 0x0aa1,
324 0x0aa2, 0x0aa3, 0x0aa4, 0x0aa5, 0x0aa6, 0x0aa7, 0x0aa8, 0x00c7,
325 0x0aaa, 0x0aab, 0x0aac, 0x0aad, 0x0aae, 0x0aaf, 0x00ce, 0x0ab0,
326 0x00d0, 0x0ab2, 0x0ab3, 0x00d3, 0x0ab5, 0x0ab6, 0x0ab7, 0x0ab8,
327 0x0ab9, 0x200e, 0x0abe, 0x0abf, 0x0ac0, 0x0ac1, 0x0ac2, 0x0ac3,
328 0x00e0, 0x0ac7, 0x0ac8, 0x0ac5, 0x00e4, 0x0acb, 0x0acc, 0x0ac9,
329 0x0acd, 0x0abc, 0x0964, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
330 0x00f0, 0x0ae6, 0x0ae7, 0x0ae8, 0x0ae9, 0x0aea, 0x0aeb, 0x0aec,
331 0x0aed, 0x0aee, 0x0aef,
334 static unichar_t gurmukhi[256] = {
335 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
336 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
337 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
338 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
339 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
340 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
341 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
342 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
343 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
344 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
345 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
346 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
347 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
348 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
349 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
350 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
351 0x00d7, 0x2212, 0x2013, 0x2014, 0x2018, 0x2019, 0x2026, 0x2022,
352 0x00a9, 0x00ae, 0x2122, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
353 0x0a71, 0x0a5c, 0x0a73, 0x0a72, 0x0a74, 0x0095, 0x0096, 0x0097,
354 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
355 0x00a0, 0x00a1, 0x0a02, 0x00a3, 0x0a05, 0x0a06, 0x0a07, 0x0a08,
356 0x0a09, 0x0a0a, 0x00aa, 0x00ab, 0x0a0f, 0x0a10, 0x00ae, 0x00af,
357 0x0a13, 0x0a14, 0x00b2, 0x0a15, 0x0a16, 0x0a17, 0x0a18, 0x0a19,
358 0x0a1a, 0x0a1b, 0x0a1c, 0x0a1d, 0x0a1e, 0x0a1f, 0x0a20, 0x0a21,
359 0x0a22, 0x0a23, 0x0a24, 0x0a25, 0x0a26, 0x0a27, 0x0a28, 0x00c7,
360 0x0a2a, 0x0a2b, 0x0a2c, 0x0a2d, 0x0a2e, 0x0a2f, 0x00ce, 0x0a30,
361 0x00d0, 0x0a32, 0x00d2, 0x00d3, 0x0a35, 0xf860, 0x00d6, 0x0a38,
362 0x0a39, 0x200e, 0x0a3e, 0x0a3f, 0x0a40, 0x0a41, 0x0a42, 0x00df,
363 0x00e0, 0x0a47, 0x0a48, 0x00e3, 0x00e4, 0x0a4b, 0x0a4c, 0x00e7,
364 0x0a4d, 0x0a3c, 0x0964, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
365 0x00f0, 0x0a66, 0x0a67, 0x0a68, 0x0a69, 0x0a6a, 0x0a6b, 0x0a6c,
366 0x0a6d, 0x0a6e, 0x0a6f,
369 static unichar_t hebrew[256] = {
370 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
371 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
372 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
373 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
374 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
375 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
376 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
377 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
378 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
379 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
380 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
381 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
382 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
383 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
384 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
385 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
386 0x00c4, 0x05f2, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1,
387 0x00e0, 0x00e2, 0x00e4, 0x00e3, 0x00e5, 0x00e7, 0x00e9, 0x00e8,
388 0x00ea, 0x00eb, 0x00ed, 0x00ec, 0x00ee, 0x00ef, 0x00f1, 0x00f3,
389 0x00f2, 0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x00f9, 0x00fb, 0x00fc,
390 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x20aa, 0x0027,
391 0x0029, 0x0028, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
392 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
393 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
394 0xf86a, 0x201e, 0xf89b, 0xf89c, 0xf89d, 0xf89e, 0x05bc, 0xfb4b,
395 0xfb35, 0x2026, 0x00a0, 0x05b8, 0x05b7, 0x05b5, 0x05b6, 0x05b4,
396 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xfb2a, 0xfb2b,
397 0x05bf, 0x05b0, 0x05b2, 0x05b1, 0x05bb, 0x05b9, 0x05b8, 0x05b3,
398 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
399 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
400 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
401 0x05e8, 0x05e9, 0x05ea, 0x007d, 0x005d, 0x007b, 0x005b, 0x007c
404 static unichar_t iceland[256] = {
405 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
406 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
407 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
408 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
409 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
410 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
411 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
412 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
413 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
414 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
415 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
416 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
417 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
418 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
419 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
420 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
421 0x00c4, 0x00c5, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1,
422 0x00e0, 0x00e2, 0x00e4, 0x00e3, 0x00e5, 0x00e7, 0x00e9, 0x00e8,
423 0x00ea, 0x00eb, 0x00ed, 0x00ec, 0x00ee, 0x00ef, 0x00f1, 0x00f3,
424 0x00f2, 0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x00f9, 0x00fb, 0x00fc,
425 0x00dd, 0x00b0, 0x00a2, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df,
426 0x00ae, 0x00a9, 0x2122, 0x00b4, 0x00a8, 0x2260, 0x00c6, 0x00d8,
427 0x221e, 0x00b1, 0x2264, 0x2265, 0x00a5, 0x00b5, 0x2202, 0x2211,
428 0x220f, 0x03c0, 0x222b, 0x00aa, 0x00ba, 0x03a9, 0x00e6, 0x00f8,
429 0x00bf, 0x00a1, 0x00ac, 0x221a, 0x0192, 0x2248, 0x2206, 0x00ab,
430 0x00bb, 0x2026, 0x00a0, 0x00c0, 0x00c3, 0x00d5, 0x0152, 0x0153,
431 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca,
432 0x00ff, 0x0178, 0x2044, 0x20ac, 0x00d0, 0x00f0, 0x00de, 0x00fe,
433 0x00fd, 0x00b7, 0x201a, 0x201e, 0x2030, 0x00c2, 0x00ca, 0x00c1,
434 0x00cb, 0x00c8, 0x00cd, 0x00ce, 0x00cf, 0x00cc, 0x00d3, 0x00d4,
435 0xf8ff, 0x00d2, 0x00da, 0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc,
436 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7
439 static unichar_t romanian[256] = {
440 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
441 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
442 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
443 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
444 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
445 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
446 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
447 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
448 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
449 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
450 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
451 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
452 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
453 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
454 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
455 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
456 0x00c4, 0x00c5, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1,
457 0x00e0, 0x00e2, 0x00e4, 0x00e3, 0x00e5, 0x00e7, 0x00e9, 0x00e8,
458 0x00ea, 0x00eb, 0x00ed, 0x00ec, 0x00ee, 0x00ef, 0x00f1, 0x00f3,
459 0x00f2, 0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x00f9, 0x00fb, 0x00fc,
460 0x2020, 0x00b0, 0x00a2, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df,
461 0x00ae, 0x00a9, 0x2122, 0x00b4, 0x00a8, 0x2260, 0x0102, 0x0218,
462 0x221e, 0x00b1, 0x2264, 0x2265, 0x00a5, 0x00b5, 0x2202, 0x2211,
463 0x220f, 0x03c0, 0x222b, 0x00aa, 0x00ba, 0x03a9, 0x0103, 0x0219,
464 0x00bf, 0x00a1, 0x00ac, 0x221a, 0x0192, 0x2248, 0x2206, 0x00ab,
465 0x00bb, 0x2026, 0x00a0, 0x00c0, 0x00c3, 0x00d5, 0x0152, 0x0153,
466 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca,
467 0x00ff, 0x0178, 0x2044, 0x20ac, 0x2039, 0x203a, 0x021a, 0x021b,
468 0x2021, 0x00b7, 0x201a, 0x201e, 0x2030, 0x00c2, 0x00ca, 0x00c1,
469 0x00cb, 0x00c8, 0x00cd, 0x00ce, 0x00cf, 0x00cc, 0x00d3, 0x00d4,
470 0xf8ff, 0x00d2, 0x00da, 0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc,
471 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7
474 unichar_t MacRomanEnc[256] = {
475 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
476 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
477 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
478 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
479 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
480 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
481 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
482 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
483 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
484 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
485 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
486 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
487 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
488 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
489 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
490 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
491 0x00c4, 0x00c5, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1,
492 0x00e0, 0x00e2, 0x00e4, 0x00e3, 0x00e5, 0x00e7, 0x00e9, 0x00e8,
493 0x00ea, 0x00eb, 0x00ed, 0x00ec, 0x00ee, 0x00ef, 0x00f1, 0x00f3,
494 0x00f2, 0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x00f9, 0x00fb, 0x00fc,
495 0x2020, 0x00b0, 0x00a2, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df,
496 0x00ae, 0x00a9, 0x2122, 0x00b4, 0x00a8, 0x2260, 0x00c6, 0x00d8,
497 0x221e, 0x00b1, 0x2264, 0x2265, 0x00a5, 0x00b5, 0x2202, 0x2211,
498 0x220f, 0x03c0, 0x222b, 0x00aa, 0x00ba, 0x03a9, 0x00e6, 0x00f8,
499 0x00bf, 0x00a1, 0x00ac, 0x221a, 0x0192, 0x2248, 0x2206, 0x00ab,
500 0x00bb, 0x2026, 0x00a0, 0x00c0, 0x00c3, 0x00d5, 0x0152, 0x0153,
501 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca,
502 0x00ff, 0x0178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
503 0x2021, 0x00b7, 0x201a, 0x201e, 0x2030, 0x00c2, 0x00ca, 0x00c1,
504 0x00cb, 0x00c8, 0x00cd, 0x00ce, 0x00cf, 0x00cc, 0x00d3, 0x00d4,
505 0xf8ff, 0x00d2, 0x00da, 0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc,
506 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7
509 static unichar_t thai[256] = {
510 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
511 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
512 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
513 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
514 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
515 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
516 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
517 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
518 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
519 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
520 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
521 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
522 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
523 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
524 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
525 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
526 0x00ab, 0x00bb, 0x2026, 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c,
527 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x201c, 0x201d, 0x0e4d,
528 0x0090, 0x2022, 0x0e31, 0x0e47, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
529 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x2018, 0x2019, 0x009f,
530 0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
531 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
532 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
533 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
534 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
535 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
536 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
537 0x0e38, 0x0e39, 0x0e3a, 0x2060, 0x200b, 0x2013, 0x2014, 0x0e3f,
538 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
539 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x2122, 0x0e4f,
540 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
541 0x0e58, 0x0e59, 0x00ae, 0x00a9,
544 static unichar_t turkish[256] = {
545 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
546 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
547 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
548 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
549 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
550 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
551 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
552 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
553 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
554 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
555 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
556 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
557 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
558 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
559 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
560 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
561 0x00c4, 0x00c5, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1,
562 0x00e0, 0x00e2, 0x00e4, 0x00e3, 0x00e5, 0x00e7, 0x00e9, 0x00e8,
563 0x00ea, 0x00eb, 0x00ed, 0x00ec, 0x00ee, 0x00ef, 0x00f1, 0x00f3,
564 0x00f2, 0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x00f9, 0x00fb, 0x00fc,
565 0x2020, 0x00b0, 0x00a2, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df,
566 0x00ae, 0x00a9, 0x2122, 0x00b4, 0x00a8, 0x2260, 0x00c6, 0x00d8,
567 0x221e, 0x00b1, 0x2264, 0x2265, 0x00a5, 0x00b5, 0x2202, 0x2211,
568 0x220f, 0x03c0, 0x222b, 0x00aa, 0x00ba, 0x03a9, 0x00e6, 0x00f8,
569 0x00bf, 0x00a1, 0x00ac, 0x221a, 0x0192, 0x2248, 0x2206, 0x00ab,
570 0x00bb, 0x2026, 0x00a0, 0x00c0, 0x00c3, 0x00d5, 0x0152, 0x0153,
571 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca,
572 0x00ff, 0x0178, 0x011e, 0x011f, 0x0130, 0x0131, 0x015e, 0x015f,
573 0x2021, 0x00b7, 0x201a, 0x201e, 0x2030, 0x00c2, 0x00ca, 0x00c1,
574 0x00cb, 0x00c8, 0x00cd, 0x00ce, 0x00cf, 0x00cc, 0x00d3, 0x00d4,
575 0xf8ff, 0x00d2, 0x00da, 0x00db, 0x00d9, 0xf8a0, 0x02c6, 0x02dc,
576 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7
579 enum script_codes {
580 sm_roman, sm_japanese, sm_tradchinese, sm_korean,
581 sm_arabic, sm_hebrew, sm_greek, sm_cyrillic,
582 sm_rsymbol, sm_devanagari, sm_gurmukhi, sm_gujarati,
583 sm_oriya, sm_bengali, sm_tamil, sm_telugu,
584 sm_kannada, sm_malayalam, sm_sinhalese, sm_burmese,
585 sm_khmer, sm_thai, sm_laotian, sm_georgian,
586 sm_armenian, sm_simpchinese, sm_tibetan, sm_mongolian,
587 sm_geez, sm_slavic, sm_vietnamese, sm_sindhi,
588 sm_max };
590 static unichar_t *macencodings[] = {
591 MacRomanEnc,
592 NULL/*Essentially SJIS*/,
593 NULL/*Essentially Big 5*/,
594 NULL/*Essentially Wansung*/,
595 arabic,
596 hebrew,
597 greek,
598 cyrillic,
599 NULL, /* rsymbol, whatever that is */
600 devanagari,
601 /*10*/ gurmukhi,
602 gujarati,
603 NULL, /* oriya */
604 NULL, /* bengali */
605 NULL, /* Tamil */
606 NULL, /* Telugu */
607 NULL, /* Kannada */
608 NULL, /* Malayalam */
609 NULL, /* Sinhalese */
610 NULL, /* Burmese */
611 /*20*/ NULL, /* Khmer */
612 thai,
613 NULL, /* Lao */
614 NULL, /* Georgian */
615 NULL, /* Armenian */
616 /*25*/ NULL,/* SimpChinese, GB2312 offset by 0x8080 to 0xa1a1 */
617 NULL, /* Tibetan */
618 NULL, /* Mongolian */
619 NULL, /* Geex/Ethiopic */
620 centeuro, /* Baltic/Slavic */
621 /*30*/ NULL, /* Vietnamese */
622 NULL, /* Extended Arabic for Sindhi */
623 NULL /* Uninterpretted */
626 /* The icelandic encoding also uses 0 (mac roman) encoding even though it's not*/
627 /* The turkish encoding also uses 0 (mac roman) encoding even though it's not*/
628 /* The croatian encoding also uses 0 (mac roman) encoding even though it's not*/
629 /* The romanian encoding also uses 0 (mac roman) encoding even though it's not*/
631 /* I've no idea what encoding code farsi uses, it isn't documented to be arabic 4, nor is it documented to have its own code */
633 static uint8 _MacScriptFromLanguage[] = {
634 sm_roman, /* English */
635 sm_roman, /* French */
636 sm_roman, /* German */
637 sm_roman, /* Italian */
638 sm_roman, /* Dutch */
639 sm_roman, /* Swedish */
640 sm_roman, /* Spanish */
641 sm_roman, /* Danish */
642 sm_roman, /* Portuguese */
643 sm_roman, /* Norwegian */
644 /*10*/ sm_hebrew, /* Hebrew */
645 sm_japanese, /* Japanese */
646 sm_arabic, /* Arabic */
647 sm_roman, /* Finnish */
648 sm_greek, /* Greek */
649 sm_roman, /* Icelandic */ /* Modified roman */
650 sm_roman, /* Maltese */
651 sm_roman, /* Turkish */ /* Modified roman */
652 sm_roman, /* Croatian */ /* Modified roman */
653 sm_tradchinese, /* Traditional Chinese */
654 /*20*/ sm_arabic, /* Urdu (I assume arabic) */
655 sm_devanagari, /* Hindi (I assume) */
656 sm_thai, /* Thai */
657 sm_korean, /* Korean */
658 sm_slavic, /* Lithuanian */
659 sm_slavic, /* Polish */
660 sm_slavic, /* Hungarian */
661 sm_slavic, /* Estonian */
662 sm_slavic, /* Latvian */
663 sm_roman, /* Sami (Lappish) */
664 /*30*/ sm_roman, /* Faroese (Icelandic) */ /* Modified roman */
665 sm_arabic, /* Farsi/Persian */ /* Modified Arabic */
666 sm_cyrillic, /* Russian */
667 sm_simpchinese, /* Simplified Chinese */
668 sm_roman, /* Flemish */
669 sm_roman, /* Irish Gaelic */
670 sm_roman, /* albanian (???) */
671 sm_roman, /* Romanian */ /* Modified roman */
672 sm_slavic, /* Czech */
673 sm_slavic, /* Slovak */
674 /*40*/ sm_slavic, /* Slovenian */
675 sm_roman, /* Yiddish */
676 sm_cyrillic, /* Serbian */
677 sm_cyrillic, /* Macedonian */
678 sm_cyrillic, /* Bulgarian */
679 sm_cyrillic, /* Ukrainian */
680 sm_cyrillic, /* Byelorussian */
681 sm_cyrillic, /* Uzbek */
682 sm_cyrillic, /* Kazakh */
683 sm_cyrillic, /* Axerbaijani (Cyrillic) */
684 /*50*/ sm_arabic, /* Axerbaijani (Arabic) */
685 sm_armenian, /* Armenian */
686 sm_georgian, /* Georgian */
687 sm_cyrillic, /* Moldavian */
688 sm_cyrillic, /* Kirghiz */
689 sm_cyrillic, /* Tajiki */
690 sm_cyrillic, /* Turkmen */
691 sm_mongolian, /* Mongolian (Mongolian) */
692 sm_cyrillic, /* Mongolian (cyrillic) */
693 sm_arabic, /* Pashto */
694 /*60*/ sm_arabic, /* Kurdish */
695 sm_devanagari, /* Kashmiri (???) */
696 sm_sindhi, /* Sindhi */
697 sm_tibetan, /* Tibetan */
698 sm_tibetan, /* Nepali (???) */
699 sm_devanagari, /* Sanskrit */
700 sm_devanagari, /* Marathi */
701 sm_bengali, /* Bengali */
702 sm_bengali, /* Assamese (???) */
703 sm_gujarati, /* Gujarati */
704 /*70*/ sm_gujarati, /* Punjabi (???) */
705 sm_oriya, /* Oriya */
706 sm_malayalam, /* Malayalam */
707 sm_kannada, /* Kannada */
708 sm_tamil, /* Tamil */
709 sm_telugu, /* Telugu */
710 sm_sinhalese, /* Sinhalese */
711 sm_burmese, /* Burmese */
712 sm_khmer, /* Khmer */
713 sm_laotian, /* Lao */
714 /*80*/ sm_vietnamese, /* Vietnamese */
715 sm_arabic, /* Indonesian */
716 sm_roman, /* Tagalog (???) */
717 sm_roman, /* Malay (roman) */
718 sm_arabic, /* Malay (arabic) */
719 sm_roman, /* Amharic (???) */
720 sm_roman, /* Tigrinya (???) */
721 sm_roman, /* Galla (???) */
722 sm_roman, /* Somali (???) */
723 sm_roman, /* Swahili (???) */
724 /*90*/ sm_roman, /* Kinyarwanda/Ruanda (???) */
725 sm_roman, /* Rundi (???) */
726 sm_roman, /* Nyanja/Chewa (???) */
727 sm_roman, /* Malagasy */
728 /*94*/ sm_roman, /* Esperanto */
729 0xff,
730 0xff,
731 0xff,
732 0xff,
733 0xff,
734 /*100*/ 0xff,
735 0xff,
736 0xff,
737 0xff,
738 0xff,
739 0xff,
740 0xff,
741 0xff,
742 0xff,
743 0xff,
744 /*110*/ 0xff,
745 0xff,
746 0xff,
747 0xff,
748 0xff,
749 0xff,
750 0xff,
751 0xff,
752 0xff,
753 0xff,
754 /*120*/ 0xff,
755 0xff,
756 0xff,
757 0xff,
758 0xff,
759 0xff,
760 0xff,
761 0xff,
762 /*128*/ sm_roman, /* Welsh */
763 sm_roman, /* Basque */
764 /*130*/ sm_roman, /* Catalan */
765 sm_roman, /* Latin */
766 sm_roman, /* Quechua (???) */
767 sm_roman, /* Guarani (???) */
768 sm_roman, /* Aymara (???) */
769 sm_cyrillic, /* Tatar (???) */
770 sm_cyrillic, /* Uighur (???) */
771 sm_cyrillic, /* Dzongkha (???) */
772 sm_roman, /* Javanese (roman) */
773 sm_roman, /* Sundanese (roman) */
774 /*140*/ sm_roman, /* Galician */
775 sm_roman, /* Afrikaans */
776 sm_roman, /* Breton */
777 sm_roman, /* Inuktitut */
778 sm_roman, /* Scottish Gaelic */
779 sm_roman, /* Manx Gaelic */
780 sm_roman, /* Irish Gaelic (with dot) */
781 sm_roman, /* Tongan */
782 sm_greek, /* Greek (polytonic) */
783 sm_roman, /* Greenlandic */ /* Presumably icelandic? */
784 /*150*/ sm_roman, /* Azebaijani (roman) */
785 0xff
788 static uint16 _WinLangFromMac[] = {
789 0x409, /* English */
790 0x40c, /* French */
791 0x407, /* German */
792 0x410, /* Italian */
793 0x413, /* Dutch */
794 0x41d, /* Swedish */
795 0x40a, /* Spanish */
796 0x406, /* Danish */
797 0x416, /* Portuguese */
798 0x414, /* Norwegian */
799 /*10*/ 0x40d, /* Hebrew */
800 0x411, /* Japanese */
801 0x401, /* Arabic */
802 0x40b, /* Finnish */
803 0x408, /* Greek */
804 0x40f, /* Icelandic */
805 0x43a, /* Maltese */
806 0x41f, /* Turkish */
807 0x41a, /* Croatian */
808 0x404, /* Traditional Chinese */
809 /*20*/ 0x420, /* Urdu */
810 0x439, /* Hindi */
811 0x41e, /* Thai */
812 0x412, /* Korean */
813 0x427, /* Lithuanian */
814 0x415, /* Polish */
815 0x40e, /* Hungarian */
816 0x425, /* Estonian */
817 0x426, /* Latvian */
818 0x43b, /* Sami (Lappish) */
819 /*30*/ 0x438, /* Faroese (Icelandic) */
820 0x429, /* Farsi/Persian */
821 0x419, /* Russian */
822 0x804, /* Simplified Chinese */
823 0x813, /* Flemish */
824 0x43c, /* Irish Gaelic */
825 0x41c, /* albanian */
826 0x418, /* Romanian */
827 0x405, /* Czech */
828 0x41b, /* Slovak */
829 /*40*/ 0x424, /* Slovenian */
830 0x43d, /* Yiddish */
831 0xc1a, /* Serbian */
832 0x42f, /* Macedonian */
833 0x402, /* Bulgarian */
834 0x422, /* Ukrainian */
835 0x423, /* Byelorussian */
836 0x843, /* Uzbek */
837 0x43f, /* Kazakh */
838 0x42c, /* Azerbaijani (Cyrillic) */
839 /*50*/ 0x82c, /* Azerbaijani (Arabic) */
840 0x42b, /* Armenian */
841 0x437, /* Georgian */
842 0x818, /* Moldavian */
843 0x440, /* Kirghiz */
844 0x428, /* Tajiki */
845 0x442, /* Turkmen */
846 0x450, /* Mongolian (Mongolian) */
847 0x850, /* Mongolian (cyrillic) */
848 0x463, /* Pashto */
849 /*60*/ 0xffff, /* Kurdish */
850 0x860, /* Kashmiri */
851 0x459, /* Sindhi */
852 0xffff, /* Tibetan */
853 0x461, /* Nepali */
854 0x43b, /* Sanskrit */
855 0x44e, /* Marathi */
856 0x445, /* Bengali */
857 0x44d, /* Assamese */
858 0x447, /* Gujarati */
859 /*70*/ 0x446, /* Punjabi */
860 0x448, /* Oriya */
861 0x44c, /* Malayalam */
862 0x44b, /* Kannada */
863 0x449, /* Tamil */
864 0x44a, /* Telugu */
865 0x45b, /* Sinhalese */
866 0x455, /* Burmese */
867 0x453, /* Khmer */
868 0x454, /* Lao */
869 /*80*/ 0x42a, /* Vietnamese */
870 0x421, /* Indonesian */
871 0x464, /* Tagalog */
872 0x43e, /* Malay (latin) */
873 0x83e, /* Malay (arabic) */
874 0x45e, /* Amharic */
875 0x473, /* Tigrinya */
876 0x472, /* Galla, oromo, afan */
877 0x477, /* Somali */
878 0x441, /* Swahili */
879 /*90*/ 0xffff, /* Kinyarwanda/Ruanda */
880 0xffff, /* Rundi/Kirundi */
881 0xffff, /* Nyanja/Chewa */
882 0xffff, /* Malagasy */
883 /*94*/ 0xffff, /* Esperanto */
884 0xffff,
885 0xffff,
886 0xffff,
887 0xffff,
888 0xffff,
889 /*100*/ 0xffff,
890 0xffff,
891 0xffff,
892 0xffff,
893 0xffff,
894 0xffff,
895 0xffff,
896 0xffff,
897 0xffff,
898 0xffff,
899 /*110*/ 0xffff,
900 0xffff,
901 0xffff,
902 0xffff,
903 0xffff,
904 0xffff,
905 0xffff,
906 0xffff,
907 0xffff,
908 0xffff,
909 /*120*/ 0xffff,
910 0xffff,
911 0xffff,
912 0xffff,
913 0xffff,
914 0xffff,
915 0xffff,
916 0xffff,
917 /*128*/ 0x452, /* Welsh */
918 0x42d, /* Basque */
919 /*130*/ 0x403, /* Catalan */
920 0x476, /* Latin */
921 0xffff, /* Quechua */
922 0x474, /* Guarani */
923 0xffff, /* Aymara */
924 0x444, /* Tatar */
925 0xffff, /* Uighur */
926 0xffff, /* Dzongkha/Bhutani */
927 0xffff, /* Javanese (roman) */
928 0xffff, /* Sundanese (roman) */
929 /*140*/ 0x456, /* Galician */
930 0x436, /* Afrikaans */
931 0xffff, /* Breton */
932 0x45d, /* Inuktitut */
933 0x43c, /* Scottish Gaelic */
934 0xc3c, /* Manx Gaelic */
935 0x83c, /* Irish Gaelic (with dot) */
936 0xffff, /* Tongan */
937 0xffff, /* Greek (polytonic) */
938 0xffff, /* Greenlandic */ /* Presumably icelandic? */
939 /*150*/ 0x42c, /* Azebaijani (roman) */
940 0xffff
943 static char *LanguageCodesFromMacLang[] = {
944 "en", /* English */
945 "fr", /* French */
946 "de", /* German */
947 "it", /* Italian */
948 "nl", /* Dutch */
949 "sv", /* Swedish */
950 "es", /* Spanish */
951 "da", /* Danish */
952 "pt", /* Portuguese */
953 "no", /* Norwegian */
954 /*10*/ "he", /* Hebrew */
955 "ja", /* Japanese */
956 "ar", /* Arabic */
957 "fi", /* Finnish */
958 "el", /* Greek */
959 "is", /* Icelandic */
960 "ml", /* Maltese */
961 "tr", /* Turkish */
962 "hr", /* Croatian */
963 "zh_TW", /* Traditional Chinese */ /* zh_HK */
964 /*20*/ "ur", /* Urdu */
965 "hi", /* Hindi */
966 "th", /* Thai */
967 "ko", /* Korean */
968 "lt", /* Lithuanian */
969 "pl", /* Polish */
970 "hu", /* Hungarian */
971 "et", /* Estonian */
972 "lv", /* Latvian */
973 "smi", /* Sami (Lappish) */
974 /*30*/ "fo", /* Faroese (Icelandic) */
975 "fa", /* Farsi/Persian */
976 "ru", /* Russian */
977 "zh_CN", /* Simplified Chinese */
978 "nl_BE", /* Flemish */ /* Flemish doesn't rate a language code, use dutch */
979 "ga", /* Irish Gaelic */
980 "sq", /* albanian */
981 "ro", /* Romanian */
982 "cs", /* Czech */
983 "sk", /* Slovak */
984 /*40*/ "sl", /* Slovenian */
985 "yi", /* Yiddish */
986 "sr", /* Serbian */
987 "mk", /* Macedonian */
988 "bg", /* Bulgarian */
989 "uk", /* Ukrainian */
990 "be", /* Byelorussian */
991 "uz", /* Uzbek */
992 "kk", /* Kazakh */
993 "az", /* Axerbaijani (Cyrillic) */
994 /*50*/ "az", /* Axerbaijani (Arabic) */
995 "hy", /* Armenian */
996 "ka", /* Georgian */
997 "mo", /* Moldavian */
998 "ky", /* Kirghiz */
999 "tg", /* Tajiki */
1000 "tk", /* Turkmen */
1001 "mn", /* Mongolian (Mongolian) */
1002 "mn", /* Mongolian (cyrillic) */
1003 "ps", /* Pashto */
1004 /*60*/ "ku", /* Kurdish */
1005 "ks", /* Kashmiri */
1006 "sd", /* Sindhi */
1007 "bo", /* Tibetan */
1008 "ne", /* Nepali */
1009 "sa", /* Sanskrit */
1010 "mr", /* Marathi */
1011 "bn", /* Bengali */
1012 "as", /* Assamese */
1013 "gu", /* Gujarati */
1014 /*70*/ "pa", /* Punjabi */
1015 "or", /* Oriya */
1016 "mal", /* Malayalam */
1017 "kn", /* Kannada */
1018 "ta", /* Tamil */
1019 "te", /* Telugu */
1020 "si", /* Sinhalese */
1021 "my", /* Burmese */
1022 "km", /* Khmer */
1023 "lo", /* Lao */
1024 /*80*/ "vi", /* Vietnamese */
1025 "id", /* Indonesian */
1026 "tl", /* Tagalog */
1027 "ms", /* Malay (roman) */
1028 "ms", /* Malay (arabic) */
1029 "am", /* Amharic */
1030 "ti", /* Tigrinya */
1031 "om", /* Galla */
1032 "so", /* Somali */
1033 "sw", /* Swahili */
1034 /*90*/ "rw", /* Kinyarwanda/Ruanda */
1035 "rn", /* Rundi */
1036 "nya", /* Nyanja/Chewa */
1037 "mg", /* Malagasy */
1038 /*94*/ "eo", /* Esperanto */
1039 NULL,
1040 NULL,
1041 NULL,
1042 NULL,
1043 NULL,
1044 /*100*/ NULL,
1045 NULL,
1046 NULL,
1047 NULL,
1048 NULL,
1049 NULL,
1050 NULL,
1051 NULL,
1052 NULL,
1053 NULL,
1054 /*110*/ NULL,
1055 NULL,
1056 NULL,
1057 NULL,
1058 NULL,
1059 NULL,
1060 NULL,
1061 NULL,
1062 NULL,
1063 NULL,
1064 /*120*/ NULL,
1065 NULL,
1066 NULL,
1067 NULL,
1068 NULL,
1069 NULL,
1070 NULL,
1071 NULL,
1072 /*128*/ "cy", /* Welsh */
1073 "eu", /* Basque */
1074 /*130*/ "ca", /* Catalan */
1075 "la", /* Latin */
1076 "qu", /* Quechua */
1077 "gn", /* Guarani */
1078 "ay", /* Aymara */
1079 "tt", /* Tatar */
1080 "ug", /* Uighur */
1081 "dz", /* Dzongkha */
1082 "jv", /* Javanese (roman) */
1083 "su", /* Sundanese (roman) */
1084 /*140*/ "gl", /* Galician */
1085 "af", /* Afrikaans */
1086 "be", /* Breton */
1087 "iu", /* Inuktitut */
1088 "gd", /* Scottish Gaelic */
1089 "gv", /* Manx Gaelic */
1090 NULL, /* Irish Gaelic (with dot) */
1091 "to", /* Tongan */
1092 "grc", /* Greek (polytonic) */
1093 "kl", /* Greenlandic */ /* Presumably icelandic? */
1094 /*150*/ "az", /* Azebaijani (roman) */
1095 NULL
1098 static const unichar_t *MacEncLangToTable(int macenc,int maclang) {
1099 const unichar_t *table = macencodings[macenc];
1101 if ( maclang==15 /* Icelandic */ ||
1102 maclang==30 /* Faroese */ ||
1103 maclang==149 /* Greenlandic */ )
1104 table = iceland;
1105 else if ( maclang == 17 /* turkish */ )
1106 table = turkish;
1107 else if ( maclang == 18 /* croatian */ )
1108 table = croatian;
1109 else if ( maclang == 37 /* romanian */ )
1110 table = romanian;
1111 else if ( maclang == 31 /* Farsi/Persian */ )
1112 table = farsi;
1113 return( table );
1116 char *MacStrToUtf8(const char *str,int macenc,int maclang) {
1117 const unichar_t *table;
1118 char *ret, *rpt;
1119 const uint8 *ustr = (uint8 *) str;
1121 if ( str==NULL )
1122 return( NULL );
1124 if ( macenc==sm_japanese || macenc==sm_korean || macenc==sm_tradchinese ||
1125 macenc == sm_simpchinese ) {
1126 Encoding *enc = FindOrMakeEncoding(macenc==sm_japanese ? "Sjis" :
1127 macenc==sm_korean ? "EUC-KR" :
1128 macenc==sm_tradchinese ? "Big5" :
1129 "EUC-CN" );
1130 iconv_t *toutf8;
1131 ICONV_CONST char *in;
1132 char *out;
1133 size_t inlen, outlen;
1134 if ( enc==NULL )
1135 return( NULL );
1136 #ifdef UNICHAR_16
1137 toutf8 = iconv_open("UCS2",enc->iconv_name!=NULL?enc->iconv_name:enc->enc_name);
1138 #else
1139 toutf8 = iconv_open("UCS4",enc->iconv_name!=NULL?enc->iconv_name:enc->enc_name);
1140 #endif
1141 if ( toutf8==(iconv_t) -1 || toutf8==NULL )
1142 return( NULL );
1143 in = (char *) str;
1144 inlen = strlen(in);
1145 outlen = (inlen+1)*4;
1146 out = (char *) (ret = galloc(outlen+2));
1147 if(iconv(toutf8,&in,&inlen,&out,&outlen)==-1){
1148 if (ret) free(ret) ;
1149 if (toutf8) iconv_close(toutf8);
1150 return( NULL );}
1151 out[0] = '\0';
1152 iconv_close(toutf8);
1153 #ifdef UNICHAR_16
1154 toutf8 = iconv_open("UTF-8","UCS2");
1155 #else
1156 toutf8 = iconv_open("UTF-8","UCS4");
1157 #endif
1158 if ( toutf8==(iconv_t) -1 || toutf8==NULL ){
1159 if (ret) free(ret);
1160 if (toutf8) iconv_close(toutf8);
1161 return( NULL );}
1162 in = (char *) strdup(ret);
1163 inlen = strlen(in);
1164 outlen = (inlen+1)*4;
1165 out = (char *) (ret = grealloc(ret,outlen+2));
1166 if(iconv(toutf8,&in,&inlen,&out,&outlen)==-1)
1167 return( NULL );
1168 out[0] = '\0';
1169 iconv_close(toutf8);
1170 free(in);
1171 return( ret );
1174 if ( macenc<0 || macenc>31 ) {
1175 IError( "Invalid mac encoding %d.\n", macenc );
1176 return( NULL );
1178 table = MacEncLangToTable(macenc,maclang);
1180 if ( table==NULL )
1181 return( NULL );
1183 ret = galloc((strlen(str)+1)*3);
1184 for ( rpt = ret; *ustr; ++ustr ) {
1185 int ch = table[*ustr];
1186 rpt = utf8_idpb(rpt,ch);
1188 *rpt = '\0';
1189 return( ret );
1192 uint8 MacEncFromMacLang(int maclang) {
1193 if ( maclang<0 || maclang>=(int)(sizeof(_MacScriptFromLanguage)/sizeof(_MacScriptFromLanguage[0])))
1194 return( 0xff );
1196 return( _MacScriptFromLanguage[maclang] );
1199 uint16 WinLangFromMac(int maclang) {
1201 if ( maclang<0 || maclang>=(int)(sizeof(_WinLangFromMac)/sizeof(_WinLangFromMac[0])))
1202 return( 0xffff );
1204 return( _WinLangFromMac[maclang] );
1207 uint16 WinLangToMac(int winlang) {
1208 int i;
1210 for ( i=0; i<(int)(sizeof(_WinLangFromMac)/sizeof(_WinLangFromMac[0])); ++i )
1211 if ( _WinLangFromMac[i] == winlang )
1212 return( i );
1214 winlang &= 0xff;
1215 for ( i=0; i<(int)(sizeof(_WinLangFromMac)/sizeof(_WinLangFromMac[0])); ++i )
1216 if ( (_WinLangFromMac[i]&0xff) == winlang )
1217 return( i );
1219 return( 0xffff );
1222 int CanEncodingWinLangAsMac(int winlang) {
1223 int maclang = WinLangToMac(winlang);
1224 int macenc = MacEncFromMacLang(maclang);
1226 if ( macenc==0xff )
1227 return( false );
1228 if ( macencodings[macenc]==NULL )
1229 return( false );
1231 return( true );
1234 const int32 *MacEncToUnicode(int script,int lang) {
1235 static int32 temp[256];
1236 int i;
1237 const unichar_t *table;
1239 table = MacEncLangToTable(script,lang);
1240 if ( table==NULL )
1241 return( NULL );
1242 for ( i=0; i<256; ++i )
1243 temp[i] = table[i];
1244 return( temp );
1247 int MacLangFromLocale(void) {
1248 /*const char *loc = setlocale(LC_MESSAGES,NULL);*/ /* This always returns "C" for me, even when it shouldn't be */
1249 const char *loc;
1250 static int found=-1;
1251 int i;
1253 if ( found!=-1 )
1254 return( found );
1256 loc = getenv("LC_ALL");
1257 if ( loc==NULL ) loc = getenv("LC_MESSAGES");
1258 if ( loc==NULL ) loc = getenv("LANG");
1260 if ( loc==NULL ) {
1261 found=0; /* Default to english */
1262 return(found);
1264 if ( strncmp(loc,"nl_BE",5)==0 ) {
1265 found = 34;
1266 return( found );
1268 for ( i=0; i<(int)(sizeof(LanguageCodesFromMacLang)/sizeof(LanguageCodesFromMacLang[0])); ++i ) {
1269 if ( LanguageCodesFromMacLang[i]!=NULL &&
1270 strncmp(loc,LanguageCodesFromMacLang[i],strlen(LanguageCodesFromMacLang[i]))==0 ) {
1271 found = i;
1272 return( found );
1275 if ( strncmp(loc,"zh_HK",2)==0 ) /* I think there are other traditional locales than Hong Kong and Taiwan (?Singapore?) so any chinese we don't recognize */
1276 found = 19;
1277 else
1278 found = 0;
1279 return( found );
1282 static struct { char *name; int code; } localmaclang[] = {
1283 {N_("English"), 0},
1284 {N_("French"), 1},
1285 {N_("German"), 2},
1286 {N_("Italian"), 3},
1287 {N_("Dutch"), 4},
1288 {N_("Swedish"), 5},
1289 {N_("Spanish"), 6},
1290 {N_("Danish"), 7},
1291 {N_("Portuguese"), 8},
1292 {N_("Norwegian"), 9},
1293 {N_("Hebrew"), 10},
1294 {N_("Japanese"), 11},
1295 {N_("Arabic"), 12},
1296 {N_("Finnish"), 13},
1297 {N_("Greek"), 14},
1298 {N_("Icelandic"), 15},
1299 {N_("Maltese"), 16},
1300 {N_("Turkish"), 17},
1301 {N_("Croatian"), 18},
1302 {N_("Traditional Chinese"), 19},
1303 {N_("Urdu"), 20},
1304 {N_("Hindi"), 21},
1305 {N_("Thai"), 22},
1306 {N_("Korean"), 23},
1307 {N_("Lithuanian"), 24},
1308 {N_("Polish"), 25},
1309 {N_("Hungarian"), 26},
1310 {N_("Estonian"), 27},
1311 {N_("Latvian"), 28},
1312 {N_("Sami (Lappish)"), 29},
1313 {N_("Faroese (Icelandic)"), 30},
1314 /* GT: See the long comment at "Property|New" */
1315 /* GT: The msgstr should contain a translation of "Farsi/Persian"), ignore "" */
1316 {N_("Farsi/Persian"), 31},
1317 {N_("Russian"), 32},
1318 {N_("Simplified Chinese"), 33},
1319 {N_("Flemish"), 34},
1320 {N_("Irish Gaelic"), 35},
1321 {N_("Albanian"), 36},
1322 {N_("Romanian"), 37},
1323 {N_("Czech"), 38},
1324 {N_("Slovak"), 39},
1325 {N_("Slovenian"), 40},
1326 {N_("Yiddish"), 41},
1327 {N_("Serbian"), 42},
1328 {N_("Macedonian"), 43},
1329 {N_("Bulgarian"), 44},
1330 {N_("Ukrainian"), 45},
1331 {N_("Byelorussian"), 46},
1332 {N_("Uzbek"), 47},
1333 {N_("Kazakh"), 48},
1334 {N_("Axerbaijani (Cyrillic)"), 49},
1335 {N_("Axerbaijani (Arabic)"), 50},
1336 {N_("Armenian"), 51},
1337 {N_("Georgian"), 52},
1338 {N_("Moldavian"), 53},
1339 {N_("Kirghiz"), 54},
1340 {N_("Tajiki"), 55},
1341 {N_("Turkmen"), 56},
1342 {N_("Mongolian (Mongolian)"), 57},
1343 {N_("Mongolian (cyrillic)"), 58},
1344 {N_("Pashto"), 59},
1345 {N_("Kurdish"), 60},
1346 {N_("Kashmiri"), 61},
1347 {N_("Sindhi"), 62},
1348 {N_("Tibetan"), 63},
1349 {N_("Nepali"), 64},
1350 {N_("Sanskrit"), 65},
1351 {N_("Marathi"), 66},
1352 {N_("Bengali"), 67},
1353 {N_("Assamese"), 68},
1354 {N_("Gujarati"), 69},
1355 {N_("Punjabi"), 70},
1356 {N_("Oriya"), 71},
1357 {N_("Malayalam"), 72},
1358 {N_("Kannada"), 73},
1359 {N_("Tamil"), 74},
1360 {N_("Telugu"), 75},
1361 {N_("Sinhalese"), 76},
1362 {N_("Burmese"), 77},
1363 {N_("Khmer"), 78},
1364 {N_("Lao"), 79},
1365 {N_("Vietnamese"), 80},
1366 {N_("Indonesian"), 81},
1367 {N_("Tagalog"), 82},
1368 {N_("Malay (roman)"), 83},
1369 {N_("Malay (arabic)"), 84},
1370 {N_("Amharic"), 85},
1371 {N_("Tigrinya"), 86},
1372 {N_("Galla"), 87},
1373 {N_("Somali"), 88},
1374 {N_("Swahili"), 89},
1375 {N_("Kinyarwanda/Ruanda"), 90},
1376 {N_("Rundi"), 91},
1377 {N_("Nyanja/Chewa"), 92},
1378 {N_("Malagasy"), 93},
1379 {N_("Esperanto"), 94},
1380 {N_("Welsh"), 128},
1381 {N_("Basque"), 129},
1382 {N_("Catalan"), 130},
1383 {N_("Latin"), 131},
1384 {N_("Quechua"), 132},
1385 {N_("Guarani"), 133},
1386 {N_("Aymara"), 134},
1387 {N_("Tatar"), 135},
1388 {N_("Uighur"), 136},
1389 {N_("Dzongkha"), 137},
1390 {N_("Javanese (roman)"), 138},
1391 {N_("Sundanese (roman)"), 139},
1392 {N_("Galician"), 140},
1393 {N_("Afrikaans"), 141},
1394 {N_("Breton"), 142},
1395 {N_("Inuktitut"), 143},
1396 {N_("Scottish Gaelic"), 144},
1397 {N_("Manx Gaelic"), 145},
1398 {N_("Irish Gaelic (with dot)"), 146},
1399 {N_("Tongan"), 147},
1400 {N_("Greek (polytonic)"), 148},
1401 {N_("Greenlandic"), 149},
1402 {N_("Azebaijani (roman)"), 150},
1403 { NULL, 0 }};
1405 char *MacLanguageFromCode(int code) {
1406 int i;
1408 if ( code==-1 )
1409 return( _("Unspecified Language") );
1411 for ( i=0; localmaclang[i].name!=NULL; ++i )
1412 if ( code == localmaclang[i].code )
1413 return( _(localmaclang[i].name) );
1415 return( _("Unknown Language"));