1 /* This file is part of GNU Dico
2    Copyright (C) 2007-2020 Sergey Poznyakoff
3 
4    GNU Dico is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3, or (at your option)
7    any later version.
8 
9    GNU Dico is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with GNU Dico.  If not, see <http://www.gnu.org/licenses/>. */
16 
17 #include <config.h>
18 #include <dico.h>
19 #include <limits.h>
20 #include <errno.h>
21 #include <string.h>
22 
23 struct unicase_info_st {
24     unsigned toupper;
25     unsigned tolower;
26     unsigned sort;
27 };
28 
29 typedef struct unicase_info_st MY_UNICASE_INFO;
30 
31 /* UTF tables written by Alexander Barkov <bar@udm.net> */
32 static MY_UNICASE_INFO plane00[] = {
33     {0x0000, 0x0000, 0x0000}, {0x0001, 0x0001, 0x0001},
34     {0x0002, 0x0002, 0x0002}, {0x0003, 0x0003, 0x0003},
35     {0x0004, 0x0004, 0x0004}, {0x0005, 0x0005, 0x0005},
36     {0x0006, 0x0006, 0x0006}, {0x0007, 0x0007, 0x0007},
37     {0x0008, 0x0008, 0x0008}, {0x0009, 0x0009, 0x0009},
38     {0x000A, 0x000A, 0x000A}, {0x000B, 0x000B, 0x000B},
39     {0x000C, 0x000C, 0x000C}, {0x000D, 0x000D, 0x000D},
40     {0x000E, 0x000E, 0x000E}, {0x000F, 0x000F, 0x000F},
41     {0x0010, 0x0010, 0x0010}, {0x0011, 0x0011, 0x0011},
42     {0x0012, 0x0012, 0x0012}, {0x0013, 0x0013, 0x0013},
43     {0x0014, 0x0014, 0x0014}, {0x0015, 0x0015, 0x0015},
44     {0x0016, 0x0016, 0x0016}, {0x0017, 0x0017, 0x0017},
45     {0x0018, 0x0018, 0x0018}, {0x0019, 0x0019, 0x0019},
46     {0x001A, 0x001A, 0x001A}, {0x001B, 0x001B, 0x001B},
47     {0x001C, 0x001C, 0x001C}, {0x001D, 0x001D, 0x001D},
48     {0x001E, 0x001E, 0x001E}, {0x001F, 0x001F, 0x001F},
49     {0x0020, 0x0020, 0x0020}, {0x0021, 0x0021, 0x0021},
50     {0x0022, 0x0022, 0x0022}, {0x0023, 0x0023, 0x0023},
51     {0x0024, 0x0024, 0x0024}, {0x0025, 0x0025, 0x0025},
52     {0x0026, 0x0026, 0x0026}, {0x0027, 0x0027, 0x0027},
53     {0x0028, 0x0028, 0x0028}, {0x0029, 0x0029, 0x0029},
54     {0x002A, 0x002A, 0x002A}, {0x002B, 0x002B, 0x002B},
55     {0x002C, 0x002C, 0x002C}, {0x002D, 0x002D, 0x002D},
56     {0x002E, 0x002E, 0x002E}, {0x002F, 0x002F, 0x002F},
57     {0x0030, 0x0030, 0x0030}, {0x0031, 0x0031, 0x0031},
58     {0x0032, 0x0032, 0x0032}, {0x0033, 0x0033, 0x0033},
59     {0x0034, 0x0034, 0x0034}, {0x0035, 0x0035, 0x0035},
60     {0x0036, 0x0036, 0x0036}, {0x0037, 0x0037, 0x0037},
61     {0x0038, 0x0038, 0x0038}, {0x0039, 0x0039, 0x0039},
62     {0x003A, 0x003A, 0x003A}, {0x003B, 0x003B, 0x003B},
63     {0x003C, 0x003C, 0x003C}, {0x003D, 0x003D, 0x003D},
64     {0x003E, 0x003E, 0x003E}, {0x003F, 0x003F, 0x003F},
65     {0x0040, 0x0040, 0x0040}, {0x0041, 0x0061, 0x0041},
66     {0x0042, 0x0062, 0x0042}, {0x0043, 0x0063, 0x0043},
67     {0x0044, 0x0064, 0x0044}, {0x0045, 0x0065, 0x0045},
68     {0x0046, 0x0066, 0x0046}, {0x0047, 0x0067, 0x0047},
69     {0x0048, 0x0068, 0x0048}, {0x0049, 0x0069, 0x0049},
70     {0x004A, 0x006A, 0x004A}, {0x004B, 0x006B, 0x004B},
71     {0x004C, 0x006C, 0x004C}, {0x004D, 0x006D, 0x004D},
72     {0x004E, 0x006E, 0x004E}, {0x004F, 0x006F, 0x004F},
73     {0x0050, 0x0070, 0x0050}, {0x0051, 0x0071, 0x0051},
74     {0x0052, 0x0072, 0x0052}, {0x0053, 0x0073, 0x0053},
75     {0x0054, 0x0074, 0x0054}, {0x0055, 0x0075, 0x0055},
76     {0x0056, 0x0076, 0x0056}, {0x0057, 0x0077, 0x0057},
77     {0x0058, 0x0078, 0x0058}, {0x0059, 0x0079, 0x0059},
78     {0x005A, 0x007A, 0x005A}, {0x005B, 0x005B, 0x005B},
79     {0x005C, 0x005C, 0x005C}, {0x005D, 0x005D, 0x005D},
80     {0x005E, 0x005E, 0x005E}, {0x005F, 0x005F, 0x005F},
81     {0x0060, 0x0060, 0x0060}, {0x0041, 0x0061, 0x0041},
82     {0x0042, 0x0062, 0x0042}, {0x0043, 0x0063, 0x0043},
83     {0x0044, 0x0064, 0x0044}, {0x0045, 0x0065, 0x0045},
84     {0x0046, 0x0066, 0x0046}, {0x0047, 0x0067, 0x0047},
85     {0x0048, 0x0068, 0x0048}, {0x0049, 0x0069, 0x0049},
86     {0x004A, 0x006A, 0x004A}, {0x004B, 0x006B, 0x004B},
87     {0x004C, 0x006C, 0x004C}, {0x004D, 0x006D, 0x004D},
88     {0x004E, 0x006E, 0x004E}, {0x004F, 0x006F, 0x004F},
89     {0x0050, 0x0070, 0x0050}, {0x0051, 0x0071, 0x0051},
90     {0x0052, 0x0072, 0x0052}, {0x0053, 0x0073, 0x0053},
91     {0x0054, 0x0074, 0x0054}, {0x0055, 0x0075, 0x0055},
92     {0x0056, 0x0076, 0x0056}, {0x0057, 0x0077, 0x0057},
93     {0x0058, 0x0078, 0x0058}, {0x0059, 0x0079, 0x0059},
94     {0x005A, 0x007A, 0x005A}, {0x007B, 0x007B, 0x007B},
95     {0x007C, 0x007C, 0x007C}, {0x007D, 0x007D, 0x007D},
96     {0x007E, 0x007E, 0x007E}, {0x007F, 0x007F, 0x007F},
97     {0x0080, 0x0080, 0x0080}, {0x0081, 0x0081, 0x0081},
98     {0x0082, 0x0082, 0x0082}, {0x0083, 0x0083, 0x0083},
99     {0x0084, 0x0084, 0x0084}, {0x0085, 0x0085, 0x0085},
100     {0x0086, 0x0086, 0x0086}, {0x0087, 0x0087, 0x0087},
101     {0x0088, 0x0088, 0x0088}, {0x0089, 0x0089, 0x0089},
102     {0x008A, 0x008A, 0x008A}, {0x008B, 0x008B, 0x008B},
103     {0x008C, 0x008C, 0x008C}, {0x008D, 0x008D, 0x008D},
104     {0x008E, 0x008E, 0x008E}, {0x008F, 0x008F, 0x008F},
105     {0x0090, 0x0090, 0x0090}, {0x0091, 0x0091, 0x0091},
106     {0x0092, 0x0092, 0x0092}, {0x0093, 0x0093, 0x0093},
107     {0x0094, 0x0094, 0x0094}, {0x0095, 0x0095, 0x0095},
108     {0x0096, 0x0096, 0x0096}, {0x0097, 0x0097, 0x0097},
109     {0x0098, 0x0098, 0x0098}, {0x0099, 0x0099, 0x0099},
110     {0x009A, 0x009A, 0x009A}, {0x009B, 0x009B, 0x009B},
111     {0x009C, 0x009C, 0x009C}, {0x009D, 0x009D, 0x009D},
112     {0x009E, 0x009E, 0x009E}, {0x009F, 0x009F, 0x009F},
113     {0x00A0, 0x00A0, 0x00A0}, {0x00A1, 0x00A1, 0x00A1},
114     {0x00A2, 0x00A2, 0x00A2}, {0x00A3, 0x00A3, 0x00A3},
115     {0x00A4, 0x00A4, 0x00A4}, {0x00A5, 0x00A5, 0x00A5},
116     {0x00A6, 0x00A6, 0x00A6}, {0x00A7, 0x00A7, 0x00A7},
117     {0x00A8, 0x00A8, 0x00A8}, {0x00A9, 0x00A9, 0x00A9},
118     {0x00AA, 0x00AA, 0x00AA}, {0x00AB, 0x00AB, 0x00AB},
119     {0x00AC, 0x00AC, 0x00AC}, {0x00AD, 0x00AD, 0x00AD},
120     {0x00AE, 0x00AE, 0x00AE}, {0x00AF, 0x00AF, 0x00AF},
121     {0x00B0, 0x00B0, 0x00B0}, {0x00B1, 0x00B1, 0x00B1},
122     {0x00B2, 0x00B2, 0x00B2}, {0x00B3, 0x00B3, 0x00B3},
123     {0x00B4, 0x00B4, 0x00B4}, {0x039C, 0x00B5, 0x039C},
124     {0x00B6, 0x00B6, 0x00B6}, {0x00B7, 0x00B7, 0x00B7},
125     {0x00B8, 0x00B8, 0x00B8}, {0x00B9, 0x00B9, 0x00B9},
126     {0x00BA, 0x00BA, 0x00BA}, {0x00BB, 0x00BB, 0x00BB},
127     {0x00BC, 0x00BC, 0x00BC}, {0x00BD, 0x00BD, 0x00BD},
128     {0x00BE, 0x00BE, 0x00BE}, {0x00BF, 0x00BF, 0x00BF},
129     {0x00C0, 0x00E0, 0x0041}, {0x00C1, 0x00E1, 0x0041},
130     {0x00C2, 0x00E2, 0x0041}, {0x00C3, 0x00E3, 0x0041},
131     {0x00C4, 0x00E4, 0x0041}, {0x00C5, 0x00E5, 0x0041},
132     {0x00C6, 0x00E6, 0x00C6}, {0x00C7, 0x00E7, 0x0043},
133     {0x00C8, 0x00E8, 0x0045}, {0x00C9, 0x00E9, 0x0045},
134     {0x00CA, 0x00EA, 0x0045}, {0x00CB, 0x00EB, 0x0045},
135     {0x00CC, 0x00EC, 0x0049}, {0x00CD, 0x00ED, 0x0049},
136     {0x00CE, 0x00EE, 0x0049}, {0x00CF, 0x00EF, 0x0049},
137     {0x00D0, 0x00F0, 0x00D0}, {0x00D1, 0x00F1, 0x004E},
138     {0x00D2, 0x00F2, 0x004F}, {0x00D3, 0x00F3, 0x004F},
139     {0x00D4, 0x00F4, 0x004F}, {0x00D5, 0x00F5, 0x004F},
140     {0x00D6, 0x00F6, 0x004F}, {0x00D7, 0x00D7, 0x00D7},
141     {0x00D8, 0x00F8, 0x00D8}, {0x00D9, 0x00F9, 0x0055},
142     {0x00DA, 0x00FA, 0x0055}, {0x00DB, 0x00FB, 0x0055},
143     {0x00DC, 0x00FC, 0x0055}, {0x00DD, 0x00FD, 0x0059},
144     {0x00DE, 0x00FE, 0x00DE}, {0x00DF, 0x00DF, 0x00DF},
145     {0x00C0, 0x00E0, 0x0041}, {0x00C1, 0x00E1, 0x0041},
146     {0x00C2, 0x00E2, 0x0041}, {0x00C3, 0x00E3, 0x0041},
147     {0x00C4, 0x00E4, 0x0041}, {0x00C5, 0x00E5, 0x0041},
148     {0x00C6, 0x00E6, 0x00C6}, {0x00C7, 0x00E7, 0x0043},
149     {0x00C8, 0x00E8, 0x0045}, {0x00C9, 0x00E9, 0x0045},
150     {0x00CA, 0x00EA, 0x0045}, {0x00CB, 0x00EB, 0x0045},
151     {0x00CC, 0x00EC, 0x0049}, {0x00CD, 0x00ED, 0x0049},
152     {0x00CE, 0x00EE, 0x0049}, {0x00CF, 0x00EF, 0x0049},
153     {0x00D0, 0x00F0, 0x00D0}, {0x00D1, 0x00F1, 0x004E},
154     {0x00D2, 0x00F2, 0x004F}, {0x00D3, 0x00F3, 0x004F},
155     {0x00D4, 0x00F4, 0x004F}, {0x00D5, 0x00F5, 0x004F},
156     {0x00D6, 0x00F6, 0x004F}, {0x00F7, 0x00F7, 0x00F7},
157     {0x00D8, 0x00F8, 0x00D8}, {0x00D9, 0x00F9, 0x0055},
158     {0x00DA, 0x00FA, 0x0055}, {0x00DB, 0x00FB, 0x0055},
159     {0x00DC, 0x00FC, 0x0055}, {0x00DD, 0x00FD, 0x0059},
160     {0x00DE, 0x00FE, 0x00DE}, {0x0178, 0x00FF, 0x0059}
161 };
162 
163 static MY_UNICASE_INFO plane01[] = {
164     {0x0100, 0x0101, 0x0041}, {0x0100, 0x0101, 0x0041},
165     {0x0102, 0x0103, 0x0041}, {0x0102, 0x0103, 0x0041},
166     {0x0104, 0x0105, 0x0041}, {0x0104, 0x0105, 0x0041},
167     {0x0106, 0x0107, 0x0043}, {0x0106, 0x0107, 0x0043},
168     {0x0108, 0x0109, 0x0043}, {0x0108, 0x0109, 0x0043},
169     {0x010A, 0x010B, 0x0043}, {0x010A, 0x010B, 0x0043},
170     {0x010C, 0x010D, 0x0043}, {0x010C, 0x010D, 0x0043},
171     {0x010E, 0x010F, 0x0044}, {0x010E, 0x010F, 0x0044},
172     {0x0110, 0x0111, 0x0110}, {0x0110, 0x0111, 0x0110},
173     {0x0112, 0x0113, 0x0045}, {0x0112, 0x0113, 0x0045},
174     {0x0114, 0x0115, 0x0045}, {0x0114, 0x0115, 0x0045},
175     {0x0116, 0x0117, 0x0045}, {0x0116, 0x0117, 0x0045},
176     {0x0118, 0x0119, 0x0045}, {0x0118, 0x0119, 0x0045},
177     {0x011A, 0x011B, 0x0045}, {0x011A, 0x011B, 0x0045},
178     {0x011C, 0x011D, 0x0047}, {0x011C, 0x011D, 0x0047},
179     {0x011E, 0x011F, 0x0047}, {0x011E, 0x011F, 0x0047},
180     {0x0120, 0x0121, 0x0047}, {0x0120, 0x0121, 0x0047},
181     {0x0122, 0x0123, 0x0047}, {0x0122, 0x0123, 0x0047},
182     {0x0124, 0x0125, 0x0048}, {0x0124, 0x0125, 0x0048},
183     {0x0126, 0x0127, 0x0126}, {0x0126, 0x0127, 0x0126},
184     {0x0128, 0x0129, 0x0049}, {0x0128, 0x0129, 0x0049},
185     {0x012A, 0x012B, 0x0049}, {0x012A, 0x012B, 0x0049},
186     {0x012C, 0x012D, 0x0049}, {0x012C, 0x012D, 0x0049},
187     {0x012E, 0x012F, 0x0049}, {0x012E, 0x012F, 0x0049},
188     {0x0130, 0x0069, 0x0049}, {0x0049, 0x0131, 0x0049},
189     {0x0132, 0x0133, 0x0132}, {0x0132, 0x0133, 0x0132},
190     {0x0134, 0x0135, 0x004A}, {0x0134, 0x0135, 0x004A},
191     {0x0136, 0x0137, 0x004B}, {0x0136, 0x0137, 0x004B},
192     {0x0138, 0x0138, 0x0138}, {0x0139, 0x013A, 0x004C},
193     {0x0139, 0x013A, 0x004C}, {0x013B, 0x013C, 0x004C},
194     {0x013B, 0x013C, 0x004C}, {0x013D, 0x013E, 0x004C},
195     {0x013D, 0x013E, 0x004C}, {0x013F, 0x0140, 0x013F},
196     {0x013F, 0x0140, 0x013F}, {0x0141, 0x0142, 0x0141},
197     {0x0141, 0x0142, 0x0141}, {0x0143, 0x0144, 0x004E},
198     {0x0143, 0x0144, 0x004E}, {0x0145, 0x0146, 0x004E},
199     {0x0145, 0x0146, 0x004E}, {0x0147, 0x0148, 0x004E},
200     {0x0147, 0x0148, 0x004E}, {0x0149, 0x0149, 0x0149},
201     {0x014A, 0x014B, 0x014A}, {0x014A, 0x014B, 0x014A},
202     {0x014C, 0x014D, 0x004F}, {0x014C, 0x014D, 0x004F},
203     {0x014E, 0x014F, 0x004F}, {0x014E, 0x014F, 0x004F},
204     {0x0150, 0x0151, 0x004F}, {0x0150, 0x0151, 0x004F},
205     {0x0152, 0x0153, 0x0152}, {0x0152, 0x0153, 0x0152},
206     {0x0154, 0x0155, 0x0052}, {0x0154, 0x0155, 0x0052},
207     {0x0156, 0x0157, 0x0052}, {0x0156, 0x0157, 0x0052},
208     {0x0158, 0x0159, 0x0052}, {0x0158, 0x0159, 0x0052},
209     {0x015A, 0x015B, 0x0053}, {0x015A, 0x015B, 0x0053},
210     {0x015C, 0x015D, 0x0053}, {0x015C, 0x015D, 0x0053},
211     {0x015E, 0x015F, 0x0053}, {0x015E, 0x015F, 0x0053},
212     {0x0160, 0x0161, 0x0053}, {0x0160, 0x0161, 0x0053},
213     {0x0162, 0x0163, 0x0054}, {0x0162, 0x0163, 0x0054},
214     {0x0164, 0x0165, 0x0054}, {0x0164, 0x0165, 0x0054},
215     {0x0166, 0x0167, 0x0166}, {0x0166, 0x0167, 0x0166},
216     {0x0168, 0x0169, 0x0055}, {0x0168, 0x0169, 0x0055},
217     {0x016A, 0x016B, 0x0055}, {0x016A, 0x016B, 0x0055},
218     {0x016C, 0x016D, 0x0055}, {0x016C, 0x016D, 0x0055},
219     {0x016E, 0x016F, 0x0055}, {0x016E, 0x016F, 0x0055},
220     {0x0170, 0x0171, 0x0055}, {0x0170, 0x0171, 0x0055},
221     {0x0172, 0x0173, 0x0055}, {0x0172, 0x0173, 0x0055},
222     {0x0174, 0x0175, 0x0057}, {0x0174, 0x0175, 0x0057},
223     {0x0176, 0x0177, 0x0059}, {0x0176, 0x0177, 0x0059},
224     {0x0178, 0x00FF, 0x0059}, {0x0179, 0x017A, 0x005A},
225     {0x0179, 0x017A, 0x005A}, {0x017B, 0x017C, 0x005A},
226     {0x017B, 0x017C, 0x005A}, {0x017D, 0x017E, 0x005A},
227     {0x017D, 0x017E, 0x005A}, {0x0053, 0x017F, 0x0053},
228     {0x0180, 0x0180, 0x0180}, {0x0181, 0x0253, 0x0181},
229     {0x0182, 0x0183, 0x0182}, {0x0182, 0x0183, 0x0182},
230     {0x0184, 0x0185, 0x0184}, {0x0184, 0x0185, 0x0184},
231     {0x0186, 0x0254, 0x0186}, {0x0187, 0x0188, 0x0187},
232     {0x0187, 0x0188, 0x0187}, {0x0189, 0x0256, 0x0189},
233     {0x018A, 0x0257, 0x018A}, {0x018B, 0x018C, 0x018B},
234     {0x018B, 0x018C, 0x018B}, {0x018D, 0x018D, 0x018D},
235     {0x018E, 0x01DD, 0x018E}, {0x018F, 0x0259, 0x018F},
236     {0x0190, 0x025B, 0x0190}, {0x0191, 0x0192, 0x0191},
237     {0x0191, 0x0192, 0x0191}, {0x0193, 0x0260, 0x0193},
238     {0x0194, 0x0263, 0x0194}, {0x01F6, 0x0195, 0x01F6},
239     {0x0196, 0x0269, 0x0196}, {0x0197, 0x0268, 0x0197},
240     {0x0198, 0x0199, 0x0198}, {0x0198, 0x0199, 0x0198},
241     {0x019A, 0x019A, 0x019A}, {0x019B, 0x019B, 0x019B},
242     {0x019C, 0x026F, 0x019C}, {0x019D, 0x0272, 0x019D},
243     {0x019E, 0x019E, 0x019E}, {0x019F, 0x0275, 0x019F},
244     {0x01A0, 0x01A1, 0x004F}, {0x01A0, 0x01A1, 0x004F},
245     {0x01A2, 0x01A3, 0x01A2}, {0x01A2, 0x01A3, 0x01A2},
246     {0x01A4, 0x01A5, 0x01A4}, {0x01A4, 0x01A5, 0x01A4},
247     {0x01A6, 0x0280, 0x01A6}, {0x01A7, 0x01A8, 0x01A7},
248     {0x01A7, 0x01A8, 0x01A7}, {0x01A9, 0x0283, 0x01A9},
249     {0x01AA, 0x01AA, 0x01AA}, {0x01AB, 0x01AB, 0x01AB},
250     {0x01AC, 0x01AD, 0x01AC}, {0x01AC, 0x01AD, 0x01AC},
251     {0x01AE, 0x0288, 0x01AE}, {0x01AF, 0x01B0, 0x0055},
252     {0x01AF, 0x01B0, 0x0055}, {0x01B1, 0x028A, 0x01B1},
253     {0x01B2, 0x028B, 0x01B2}, {0x01B3, 0x01B4, 0x01B3},
254     {0x01B3, 0x01B4, 0x01B3}, {0x01B5, 0x01B6, 0x01B5},
255     {0x01B5, 0x01B6, 0x01B5}, {0x01B7, 0x0292, 0x01B7},
256     {0x01B8, 0x01B9, 0x01B8}, {0x01B8, 0x01B9, 0x01B8},
257     {0x01BA, 0x01BA, 0x01BA}, {0x01BB, 0x01BB, 0x01BB},
258     {0x01BC, 0x01BD, 0x01BC}, {0x01BC, 0x01BD, 0x01BC},
259     {0x01BE, 0x01BE, 0x01BE}, {0x01F7, 0x01BF, 0x01F7},
260     {0x01C0, 0x01C0, 0x01C0}, {0x01C1, 0x01C1, 0x01C1},
261     {0x01C2, 0x01C2, 0x01C2}, {0x01C3, 0x01C3, 0x01C3},
262     {0x01C4, 0x01C6, 0x01C4}, {0x01C4, 0x01C6, 0x01C4},
263     {0x01C4, 0x01C6, 0x01C4}, {0x01C7, 0x01C9, 0x01C7},
264     {0x01C7, 0x01C9, 0x01C7}, {0x01C7, 0x01C9, 0x01C7},
265     {0x01CA, 0x01CC, 0x01CA}, {0x01CA, 0x01CC, 0x01CA},
266     {0x01CA, 0x01CC, 0x01CA}, {0x01CD, 0x01CE, 0x0041},
267     {0x01CD, 0x01CE, 0x0041}, {0x01CF, 0x01D0, 0x0049},
268     {0x01CF, 0x01D0, 0x0049}, {0x01D1, 0x01D2, 0x004F},
269     {0x01D1, 0x01D2, 0x004F}, {0x01D3, 0x01D4, 0x0055},
270     {0x01D3, 0x01D4, 0x0055}, {0x01D5, 0x01D6, 0x0055},
271     {0x01D5, 0x01D6, 0x0055}, {0x01D7, 0x01D8, 0x0055},
272     {0x01D7, 0x01D8, 0x0055}, {0x01D9, 0x01DA, 0x0055},
273     {0x01D9, 0x01DA, 0x0055}, {0x01DB, 0x01DC, 0x0055},
274     {0x01DB, 0x01DC, 0x0055}, {0x018E, 0x01DD, 0x018E},
275     {0x01DE, 0x01DF, 0x0041}, {0x01DE, 0x01DF, 0x0041},
276     {0x01E0, 0x01E1, 0x0041}, {0x01E0, 0x01E1, 0x0041},
277     {0x01E2, 0x01E3, 0x00C6}, {0x01E2, 0x01E3, 0x00C6},
278     {0x01E4, 0x01E5, 0x01E4}, {0x01E4, 0x01E5, 0x01E4},
279     {0x01E6, 0x01E7, 0x0047}, {0x01E6, 0x01E7, 0x0047},
280     {0x01E8, 0x01E9, 0x004B}, {0x01E8, 0x01E9, 0x004B},
281     {0x01EA, 0x01EB, 0x004F}, {0x01EA, 0x01EB, 0x004F},
282     {0x01EC, 0x01ED, 0x004F}, {0x01EC, 0x01ED, 0x004F},
283     {0x01EE, 0x01EF, 0x01B7}, {0x01EE, 0x01EF, 0x01B7},
284     {0x01F0, 0x01F0, 0x004A}, {0x01F1, 0x01F3, 0x01F1},
285     {0x01F1, 0x01F3, 0x01F1}, {0x01F1, 0x01F3, 0x01F1},
286     {0x01F4, 0x01F5, 0x0047}, {0x01F4, 0x01F5, 0x0047},
287     {0x01F6, 0x0195, 0x01F6}, {0x01F7, 0x01BF, 0x01F7},
288     {0x01F8, 0x01F9, 0x004E}, {0x01F8, 0x01F9, 0x004E},
289     {0x01FA, 0x01FB, 0x0041}, {0x01FA, 0x01FB, 0x0041},
290     {0x01FC, 0x01FD, 0x00C6}, {0x01FC, 0x01FD, 0x00C6},
291     {0x01FE, 0x01FF, 0x00D8}, {0x01FE, 0x01FF, 0x00D8}
292 };
293 
294 static MY_UNICASE_INFO plane02[] = {
295     {0x0200, 0x0201, 0x0041}, {0x0200, 0x0201, 0x0041},
296     {0x0202, 0x0203, 0x0041}, {0x0202, 0x0203, 0x0041},
297     {0x0204, 0x0205, 0x0045}, {0x0204, 0x0205, 0x0045},
298     {0x0206, 0x0207, 0x0045}, {0x0206, 0x0207, 0x0045},
299     {0x0208, 0x0209, 0x0049}, {0x0208, 0x0209, 0x0049},
300     {0x020A, 0x020B, 0x0049}, {0x020A, 0x020B, 0x0049},
301     {0x020C, 0x020D, 0x004F}, {0x020C, 0x020D, 0x004F},
302     {0x020E, 0x020F, 0x004F}, {0x020E, 0x020F, 0x004F},
303     {0x0210, 0x0211, 0x0052}, {0x0210, 0x0211, 0x0052},
304     {0x0212, 0x0213, 0x0052}, {0x0212, 0x0213, 0x0052},
305     {0x0214, 0x0215, 0x0055}, {0x0214, 0x0215, 0x0055},
306     {0x0216, 0x0217, 0x0055}, {0x0216, 0x0217, 0x0055},
307     {0x0218, 0x0219, 0x0053}, {0x0218, 0x0219, 0x0053},
308     {0x021A, 0x021B, 0x0054}, {0x021A, 0x021B, 0x0054},
309     {0x021C, 0x021D, 0x021C}, {0x021C, 0x021D, 0x021C},
310     {0x021E, 0x021F, 0x0048}, {0x021E, 0x021F, 0x0048},
311     {0x0220, 0x0220, 0x0220}, {0x0221, 0x0221, 0x0221},
312     {0x0222, 0x0223, 0x0222}, {0x0222, 0x0223, 0x0222},
313     {0x0224, 0x0225, 0x0224}, {0x0224, 0x0225, 0x0224},
314     {0x0226, 0x0227, 0x0041}, {0x0226, 0x0227, 0x0041},
315     {0x0228, 0x0229, 0x0045}, {0x0228, 0x0229, 0x0045},
316     {0x022A, 0x022B, 0x004F}, {0x022A, 0x022B, 0x004F},
317     {0x022C, 0x022D, 0x004F}, {0x022C, 0x022D, 0x004F},
318     {0x022E, 0x022F, 0x004F}, {0x022E, 0x022F, 0x004F},
319     {0x0230, 0x0231, 0x004F}, {0x0230, 0x0231, 0x004F},
320     {0x0232, 0x0233, 0x0059}, {0x0232, 0x0233, 0x0059},
321     {0x0234, 0x0234, 0x0234}, {0x0235, 0x0235, 0x0235},
322     {0x0236, 0x0236, 0x0236}, {0x0237, 0x0237, 0x0237},
323     {0x0238, 0x0238, 0x0238}, {0x0239, 0x0239, 0x0239},
324     {0x023A, 0x023A, 0x023A}, {0x023B, 0x023B, 0x023B},
325     {0x023C, 0x023C, 0x023C}, {0x023D, 0x023D, 0x023D},
326     {0x023E, 0x023E, 0x023E}, {0x023F, 0x023F, 0x023F},
327     {0x0240, 0x0240, 0x0240}, {0x0241, 0x0241, 0x0241},
328     {0x0242, 0x0242, 0x0242}, {0x0243, 0x0243, 0x0243},
329     {0x0244, 0x0244, 0x0244}, {0x0245, 0x0245, 0x0245},
330     {0x0246, 0x0246, 0x0246}, {0x0247, 0x0247, 0x0247},
331     {0x0248, 0x0248, 0x0248}, {0x0249, 0x0249, 0x0249},
332     {0x024A, 0x024A, 0x024A}, {0x024B, 0x024B, 0x024B},
333     {0x024C, 0x024C, 0x024C}, {0x024D, 0x024D, 0x024D},
334     {0x024E, 0x024E, 0x024E}, {0x024F, 0x024F, 0x024F},
335     {0x0250, 0x0250, 0x0250}, {0x0251, 0x0251, 0x0251},
336     {0x0252, 0x0252, 0x0252}, {0x0181, 0x0253, 0x0181},
337     {0x0186, 0x0254, 0x0186}, {0x0255, 0x0255, 0x0255},
338     {0x0189, 0x0256, 0x0189}, {0x018A, 0x0257, 0x018A},
339     {0x0258, 0x0258, 0x0258}, {0x018F, 0x0259, 0x018F},
340     {0x025A, 0x025A, 0x025A}, {0x0190, 0x025B, 0x0190},
341     {0x025C, 0x025C, 0x025C}, {0x025D, 0x025D, 0x025D},
342     {0x025E, 0x025E, 0x025E}, {0x025F, 0x025F, 0x025F},
343     {0x0193, 0x0260, 0x0193}, {0x0261, 0x0261, 0x0261},
344     {0x0262, 0x0262, 0x0262}, {0x0194, 0x0263, 0x0194},
345     {0x0264, 0x0264, 0x0264}, {0x0265, 0x0265, 0x0265},
346     {0x0266, 0x0266, 0x0266}, {0x0267, 0x0267, 0x0267},
347     {0x0197, 0x0268, 0x0197}, {0x0196, 0x0269, 0x0196},
348     {0x026A, 0x026A, 0x026A}, {0x026B, 0x026B, 0x026B},
349     {0x026C, 0x026C, 0x026C}, {0x026D, 0x026D, 0x026D},
350     {0x026E, 0x026E, 0x026E}, {0x019C, 0x026F, 0x019C},
351     {0x0270, 0x0270, 0x0270}, {0x0271, 0x0271, 0x0271},
352     {0x019D, 0x0272, 0x019D}, {0x0273, 0x0273, 0x0273},
353     {0x0274, 0x0274, 0x0274}, {0x019F, 0x0275, 0x019F},
354     {0x0276, 0x0276, 0x0276}, {0x0277, 0x0277, 0x0277},
355     {0x0278, 0x0278, 0x0278}, {0x0279, 0x0279, 0x0279},
356     {0x027A, 0x027A, 0x027A}, {0x027B, 0x027B, 0x027B},
357     {0x027C, 0x027C, 0x027C}, {0x027D, 0x027D, 0x027D},
358     {0x027E, 0x027E, 0x027E}, {0x027F, 0x027F, 0x027F},
359     {0x01A6, 0x0280, 0x01A6}, {0x0281, 0x0281, 0x0281},
360     {0x0282, 0x0282, 0x0282}, {0x01A9, 0x0283, 0x01A9},
361     {0x0284, 0x0284, 0x0284}, {0x0285, 0x0285, 0x0285},
362     {0x0286, 0x0286, 0x0286}, {0x0287, 0x0287, 0x0287},
363     {0x01AE, 0x0288, 0x01AE}, {0x0289, 0x0289, 0x0289},
364     {0x01B1, 0x028A, 0x01B1}, {0x01B2, 0x028B, 0x01B2},
365     {0x028C, 0x028C, 0x028C}, {0x028D, 0x028D, 0x028D},
366     {0x028E, 0x028E, 0x028E}, {0x028F, 0x028F, 0x028F},
367     {0x0290, 0x0290, 0x0290}, {0x0291, 0x0291, 0x0291},
368     {0x01B7, 0x0292, 0x01B7}, {0x0293, 0x0293, 0x0293},
369     {0x0294, 0x0294, 0x0294}, {0x0295, 0x0295, 0x0295},
370     {0x0296, 0x0296, 0x0296}, {0x0297, 0x0297, 0x0297},
371     {0x0298, 0x0298, 0x0298}, {0x0299, 0x0299, 0x0299},
372     {0x029A, 0x029A, 0x029A}, {0x029B, 0x029B, 0x029B},
373     {0x029C, 0x029C, 0x029C}, {0x029D, 0x029D, 0x029D},
374     {0x029E, 0x029E, 0x029E}, {0x029F, 0x029F, 0x029F},
375     {0x02A0, 0x02A0, 0x02A0}, {0x02A1, 0x02A1, 0x02A1},
376     {0x02A2, 0x02A2, 0x02A2}, {0x02A3, 0x02A3, 0x02A3},
377     {0x02A4, 0x02A4, 0x02A4}, {0x02A5, 0x02A5, 0x02A5},
378     {0x02A6, 0x02A6, 0x02A6}, {0x02A7, 0x02A7, 0x02A7},
379     {0x02A8, 0x02A8, 0x02A8}, {0x02A9, 0x02A9, 0x02A9},
380     {0x02AA, 0x02AA, 0x02AA}, {0x02AB, 0x02AB, 0x02AB},
381     {0x02AC, 0x02AC, 0x02AC}, {0x02AD, 0x02AD, 0x02AD},
382     {0x02AE, 0x02AE, 0x02AE}, {0x02AF, 0x02AF, 0x02AF},
383     {0x02B0, 0x02B0, 0x02B0}, {0x02B1, 0x02B1, 0x02B1},
384     {0x02B2, 0x02B2, 0x02B2}, {0x02B3, 0x02B3, 0x02B3},
385     {0x02B4, 0x02B4, 0x02B4}, {0x02B5, 0x02B5, 0x02B5},
386     {0x02B6, 0x02B6, 0x02B6}, {0x02B7, 0x02B7, 0x02B7},
387     {0x02B8, 0x02B8, 0x02B8}, {0x02B9, 0x02B9, 0x02B9},
388     {0x02BA, 0x02BA, 0x02BA}, {0x02BB, 0x02BB, 0x02BB},
389     {0x02BC, 0x02BC, 0x02BC}, {0x02BD, 0x02BD, 0x02BD},
390     {0x02BE, 0x02BE, 0x02BE}, {0x02BF, 0x02BF, 0x02BF},
391     {0x02C0, 0x02C0, 0x02C0}, {0x02C1, 0x02C1, 0x02C1},
392     {0x02C2, 0x02C2, 0x02C2}, {0x02C3, 0x02C3, 0x02C3},
393     {0x02C4, 0x02C4, 0x02C4}, {0x02C5, 0x02C5, 0x02C5},
394     {0x02C6, 0x02C6, 0x02C6}, {0x02C7, 0x02C7, 0x02C7},
395     {0x02C8, 0x02C8, 0x02C8}, {0x02C9, 0x02C9, 0x02C9},
396     {0x02CA, 0x02CA, 0x02CA}, {0x02CB, 0x02CB, 0x02CB},
397     {0x02CC, 0x02CC, 0x02CC}, {0x02CD, 0x02CD, 0x02CD},
398     {0x02CE, 0x02CE, 0x02CE}, {0x02CF, 0x02CF, 0x02CF},
399     {0x02D0, 0x02D0, 0x02D0}, {0x02D1, 0x02D1, 0x02D1},
400     {0x02D2, 0x02D2, 0x02D2}, {0x02D3, 0x02D3, 0x02D3},
401     {0x02D4, 0x02D4, 0x02D4}, {0x02D5, 0x02D5, 0x02D5},
402     {0x02D6, 0x02D6, 0x02D6}, {0x02D7, 0x02D7, 0x02D7},
403     {0x02D8, 0x02D8, 0x02D8}, {0x02D9, 0x02D9, 0x02D9},
404     {0x02DA, 0x02DA, 0x02DA}, {0x02DB, 0x02DB, 0x02DB},
405     {0x02DC, 0x02DC, 0x02DC}, {0x02DD, 0x02DD, 0x02DD},
406     {0x02DE, 0x02DE, 0x02DE}, {0x02DF, 0x02DF, 0x02DF},
407     {0x02E0, 0x02E0, 0x02E0}, {0x02E1, 0x02E1, 0x02E1},
408     {0x02E2, 0x02E2, 0x02E2}, {0x02E3, 0x02E3, 0x02E3},
409     {0x02E4, 0x02E4, 0x02E4}, {0x02E5, 0x02E5, 0x02E5},
410     {0x02E6, 0x02E6, 0x02E6}, {0x02E7, 0x02E7, 0x02E7},
411     {0x02E8, 0x02E8, 0x02E8}, {0x02E9, 0x02E9, 0x02E9},
412     {0x02EA, 0x02EA, 0x02EA}, {0x02EB, 0x02EB, 0x02EB},
413     {0x02EC, 0x02EC, 0x02EC}, {0x02ED, 0x02ED, 0x02ED},
414     {0x02EE, 0x02EE, 0x02EE}, {0x02EF, 0x02EF, 0x02EF},
415     {0x02F0, 0x02F0, 0x02F0}, {0x02F1, 0x02F1, 0x02F1},
416     {0x02F2, 0x02F2, 0x02F2}, {0x02F3, 0x02F3, 0x02F3},
417     {0x02F4, 0x02F4, 0x02F4}, {0x02F5, 0x02F5, 0x02F5},
418     {0x02F6, 0x02F6, 0x02F6}, {0x02F7, 0x02F7, 0x02F7},
419     {0x02F8, 0x02F8, 0x02F8}, {0x02F9, 0x02F9, 0x02F9},
420     {0x02FA, 0x02FA, 0x02FA}, {0x02FB, 0x02FB, 0x02FB},
421     {0x02FC, 0x02FC, 0x02FC}, {0x02FD, 0x02FD, 0x02FD},
422     {0x02FE, 0x02FE, 0x02FE}, {0x02FF, 0x02FF, 0x02FF}
423 };
424 
425 static MY_UNICASE_INFO plane03[] = {
426     {0x0300, 0x0300, 0x0300}, {0x0301, 0x0301, 0x0301},
427     {0x0302, 0x0302, 0x0302}, {0x0303, 0x0303, 0x0303},
428     {0x0304, 0x0304, 0x0304}, {0x0305, 0x0305, 0x0305},
429     {0x0306, 0x0306, 0x0306}, {0x0307, 0x0307, 0x0307},
430     {0x0308, 0x0308, 0x0308}, {0x0309, 0x0309, 0x0309},
431     {0x030A, 0x030A, 0x030A}, {0x030B, 0x030B, 0x030B},
432     {0x030C, 0x030C, 0x030C}, {0x030D, 0x030D, 0x030D},
433     {0x030E, 0x030E, 0x030E}, {0x030F, 0x030F, 0x030F},
434     {0x0310, 0x0310, 0x0310}, {0x0311, 0x0311, 0x0311},
435     {0x0312, 0x0312, 0x0312}, {0x0313, 0x0313, 0x0313},
436     {0x0314, 0x0314, 0x0314}, {0x0315, 0x0315, 0x0315},
437     {0x0316, 0x0316, 0x0316}, {0x0317, 0x0317, 0x0317},
438     {0x0318, 0x0318, 0x0318}, {0x0319, 0x0319, 0x0319},
439     {0x031A, 0x031A, 0x031A}, {0x031B, 0x031B, 0x031B},
440     {0x031C, 0x031C, 0x031C}, {0x031D, 0x031D, 0x031D},
441     {0x031E, 0x031E, 0x031E}, {0x031F, 0x031F, 0x031F},
442     {0x0320, 0x0320, 0x0320}, {0x0321, 0x0321, 0x0321},
443     {0x0322, 0x0322, 0x0322}, {0x0323, 0x0323, 0x0323},
444     {0x0324, 0x0324, 0x0324}, {0x0325, 0x0325, 0x0325},
445     {0x0326, 0x0326, 0x0326}, {0x0327, 0x0327, 0x0327},
446     {0x0328, 0x0328, 0x0328}, {0x0329, 0x0329, 0x0329},
447     {0x032A, 0x032A, 0x032A}, {0x032B, 0x032B, 0x032B},
448     {0x032C, 0x032C, 0x032C}, {0x032D, 0x032D, 0x032D},
449     {0x032E, 0x032E, 0x032E}, {0x032F, 0x032F, 0x032F},
450     {0x0330, 0x0330, 0x0330}, {0x0331, 0x0331, 0x0331},
451     {0x0332, 0x0332, 0x0332}, {0x0333, 0x0333, 0x0333},
452     {0x0334, 0x0334, 0x0334}, {0x0335, 0x0335, 0x0335},
453     {0x0336, 0x0336, 0x0336}, {0x0337, 0x0337, 0x0337},
454     {0x0338, 0x0338, 0x0338}, {0x0339, 0x0339, 0x0339},
455     {0x033A, 0x033A, 0x033A}, {0x033B, 0x033B, 0x033B},
456     {0x033C, 0x033C, 0x033C}, {0x033D, 0x033D, 0x033D},
457     {0x033E, 0x033E, 0x033E}, {0x033F, 0x033F, 0x033F},
458     {0x0340, 0x0340, 0x0340}, {0x0341, 0x0341, 0x0341},
459     {0x0342, 0x0342, 0x0342}, {0x0343, 0x0343, 0x0343},
460     {0x0344, 0x0344, 0x0344}, {0x0399, 0x0345, 0x0399},
461     {0x0346, 0x0346, 0x0346}, {0x0347, 0x0347, 0x0347},
462     {0x0348, 0x0348, 0x0348}, {0x0349, 0x0349, 0x0349},
463     {0x034A, 0x034A, 0x034A}, {0x034B, 0x034B, 0x034B},
464     {0x034C, 0x034C, 0x034C}, {0x034D, 0x034D, 0x034D},
465     {0x034E, 0x034E, 0x034E}, {0x034F, 0x034F, 0x034F},
466     {0x0350, 0x0350, 0x0350}, {0x0351, 0x0351, 0x0351},
467     {0x0352, 0x0352, 0x0352}, {0x0353, 0x0353, 0x0353},
468     {0x0354, 0x0354, 0x0354}, {0x0355, 0x0355, 0x0355},
469     {0x0356, 0x0356, 0x0356}, {0x0357, 0x0357, 0x0357},
470     {0x0358, 0x0358, 0x0358}, {0x0359, 0x0359, 0x0359},
471     {0x035A, 0x035A, 0x035A}, {0x035B, 0x035B, 0x035B},
472     {0x035C, 0x035C, 0x035C}, {0x035D, 0x035D, 0x035D},
473     {0x035E, 0x035E, 0x035E}, {0x035F, 0x035F, 0x035F},
474     {0x0360, 0x0360, 0x0360}, {0x0361, 0x0361, 0x0361},
475     {0x0362, 0x0362, 0x0362}, {0x0363, 0x0363, 0x0363},
476     {0x0364, 0x0364, 0x0364}, {0x0365, 0x0365, 0x0365},
477     {0x0366, 0x0366, 0x0366}, {0x0367, 0x0367, 0x0367},
478     {0x0368, 0x0368, 0x0368}, {0x0369, 0x0369, 0x0369},
479     {0x036A, 0x036A, 0x036A}, {0x036B, 0x036B, 0x036B},
480     {0x036C, 0x036C, 0x036C}, {0x036D, 0x036D, 0x036D},
481     {0x036E, 0x036E, 0x036E}, {0x036F, 0x036F, 0x036F},
482     {0x0370, 0x0370, 0x0370}, {0x0371, 0x0371, 0x0371},
483     {0x0372, 0x0372, 0x0372}, {0x0373, 0x0373, 0x0373},
484     {0x0374, 0x0374, 0x0374}, {0x0375, 0x0375, 0x0375},
485     {0x0376, 0x0376, 0x0376}, {0x0377, 0x0377, 0x0377},
486     {0x0378, 0x0378, 0x0378}, {0x0379, 0x0379, 0x0379},
487     {0x037A, 0x037A, 0x037A}, {0x037B, 0x037B, 0x037B},
488     {0x037C, 0x037C, 0x037C}, {0x037D, 0x037D, 0x037D},
489     {0x037E, 0x037E, 0x037E}, {0x037F, 0x037F, 0x037F},
490     {0x0380, 0x0380, 0x0380}, {0x0381, 0x0381, 0x0381},
491     {0x0382, 0x0382, 0x0382}, {0x0383, 0x0383, 0x0383},
492     {0x0384, 0x0384, 0x0384}, {0x0385, 0x0385, 0x0385},
493     {0x0386, 0x03AC, 0x0391}, {0x0387, 0x0387, 0x0387},
494     {0x0388, 0x03AD, 0x0395}, {0x0389, 0x03AE, 0x0397},
495     {0x038A, 0x03AF, 0x0399}, {0x038B, 0x038B, 0x038B},
496     {0x038C, 0x03CC, 0x039F}, {0x038D, 0x038D, 0x038D},
497     {0x038E, 0x03CD, 0x03A5}, {0x038F, 0x03CE, 0x03A9},
498     {0x0390, 0x0390, 0x0399}, {0x0391, 0x03B1, 0x0391},
499     {0x0392, 0x03B2, 0x0392}, {0x0393, 0x03B3, 0x0393},
500     {0x0394, 0x03B4, 0x0394}, {0x0395, 0x03B5, 0x0395},
501     {0x0396, 0x03B6, 0x0396}, {0x0397, 0x03B7, 0x0397},
502     {0x0398, 0x03B8, 0x0398}, {0x0399, 0x03B9, 0x0399},
503     {0x039A, 0x03BA, 0x039A}, {0x039B, 0x03BB, 0x039B},
504     {0x039C, 0x03BC, 0x039C}, {0x039D, 0x03BD, 0x039D},
505     {0x039E, 0x03BE, 0x039E}, {0x039F, 0x03BF, 0x039F},
506     {0x03A0, 0x03C0, 0x03A0}, {0x03A1, 0x03C1, 0x03A1},
507     {0x03A2, 0x03A2, 0x03A2}, {0x03A3, 0x03C3, 0x03A3},
508     {0x03A4, 0x03C4, 0x03A4}, {0x03A5, 0x03C5, 0x03A5},
509     {0x03A6, 0x03C6, 0x03A6}, {0x03A7, 0x03C7, 0x03A7},
510     {0x03A8, 0x03C8, 0x03A8}, {0x03A9, 0x03C9, 0x03A9},
511     {0x03AA, 0x03CA, 0x0399}, {0x03AB, 0x03CB, 0x03A5},
512     {0x0386, 0x03AC, 0x0391}, {0x0388, 0x03AD, 0x0395},
513     {0x0389, 0x03AE, 0x0397}, {0x038A, 0x03AF, 0x0399},
514     {0x03B0, 0x03B0, 0x03A5}, {0x0391, 0x03B1, 0x0391},
515     {0x0392, 0x03B2, 0x0392}, {0x0393, 0x03B3, 0x0393},
516     {0x0394, 0x03B4, 0x0394}, {0x0395, 0x03B5, 0x0395},
517     {0x0396, 0x03B6, 0x0396}, {0x0397, 0x03B7, 0x0397},
518     {0x0398, 0x03B8, 0x0398}, {0x0399, 0x03B9, 0x0399},
519     {0x039A, 0x03BA, 0x039A}, {0x039B, 0x03BB, 0x039B},
520     {0x039C, 0x03BC, 0x039C}, {0x039D, 0x03BD, 0x039D},
521     {0x039E, 0x03BE, 0x039E}, {0x039F, 0x03BF, 0x039F},
522     {0x03A0, 0x03C0, 0x03A0}, {0x03A1, 0x03C1, 0x03A1},
523     {0x03A3, 0x03C2, 0x03A3}, {0x03A3, 0x03C3, 0x03A3},
524     {0x03A4, 0x03C4, 0x03A4}, {0x03A5, 0x03C5, 0x03A5},
525     {0x03A6, 0x03C6, 0x03A6}, {0x03A7, 0x03C7, 0x03A7},
526     {0x03A8, 0x03C8, 0x03A8}, {0x03A9, 0x03C9, 0x03A9},
527     {0x03AA, 0x03CA, 0x0399}, {0x03AB, 0x03CB, 0x03A5},
528     {0x038C, 0x03CC, 0x039F}, {0x038E, 0x03CD, 0x03A5},
529     {0x038F, 0x03CE, 0x03A9}, {0x03CF, 0x03CF, 0x03CF},
530     {0x0392, 0x03D0, 0x0392}, {0x0398, 0x03D1, 0x0398},
531     {0x03D2, 0x03D2, 0x03D2}, {0x03D3, 0x03D3, 0x03D2},
532     {0x03D4, 0x03D4, 0x03D2}, {0x03A6, 0x03D5, 0x03A6},
533     {0x03A0, 0x03D6, 0x03A0}, {0x03D7, 0x03D7, 0x03D7},
534     {0x03D8, 0x03D8, 0x03D8}, {0x03D9, 0x03D9, 0x03D9},
535     {0x03DA, 0x03DB, 0x03DA}, {0x03DA, 0x03DB, 0x03DA},
536     {0x03DC, 0x03DD, 0x03DC}, {0x03DC, 0x03DD, 0x03DC},
537     {0x03DE, 0x03DF, 0x03DE}, {0x03DE, 0x03DF, 0x03DE},
538     {0x03E0, 0x03E1, 0x03E0}, {0x03E0, 0x03E1, 0x03E0},
539     {0x03E2, 0x03E3, 0x03E2}, {0x03E2, 0x03E3, 0x03E2},
540     {0x03E4, 0x03E5, 0x03E4}, {0x03E4, 0x03E5, 0x03E4},
541     {0x03E6, 0x03E7, 0x03E6}, {0x03E6, 0x03E7, 0x03E6},
542     {0x03E8, 0x03E9, 0x03E8}, {0x03E8, 0x03E9, 0x03E8},
543     {0x03EA, 0x03EB, 0x03EA}, {0x03EA, 0x03EB, 0x03EA},
544     {0x03EC, 0x03ED, 0x03EC}, {0x03EC, 0x03ED, 0x03EC},
545     {0x03EE, 0x03EF, 0x03EE}, {0x03EE, 0x03EF, 0x03EE},
546     {0x039A, 0x03F0, 0x039A}, {0x03A1, 0x03F1, 0x03A1},
547     {0x03A3, 0x03F2, 0x03A3}, {0x03F3, 0x03F3, 0x03F3},
548     {0x03F4, 0x03F4, 0x03F4}, {0x03F5, 0x03F5, 0x03F5},
549     {0x03F6, 0x03F6, 0x03F6}, {0x03F7, 0x03F7, 0x03F7},
550     {0x03F8, 0x03F8, 0x03F8}, {0x03F9, 0x03F9, 0x03F9},
551     {0x03FA, 0x03FA, 0x03FA}, {0x03FB, 0x03FB, 0x03FB},
552     {0x03FC, 0x03FC, 0x03FC}, {0x03FD, 0x03FD, 0x03FD},
553     {0x03FE, 0x03FE, 0x03FE}, {0x03FF, 0x03FF, 0x03FF}
554 };
555 
556 static MY_UNICASE_INFO plane04[] = {
557     {0x0400, 0x0450, 0x0415}, {0x0401, 0x0451, 0x0415},
558     {0x0402, 0x0452, 0x0402}, {0x0403, 0x0453, 0x0413},
559     {0x0404, 0x0454, 0x0404}, {0x0405, 0x0455, 0x0405},
560     {0x0406, 0x0456, 0x0406}, {0x0407, 0x0457, 0x0406},
561     {0x0408, 0x0458, 0x0408}, {0x0409, 0x0459, 0x0409},
562     {0x040A, 0x045A, 0x040A}, {0x040B, 0x045B, 0x040B},
563     {0x040C, 0x045C, 0x041A}, {0x040D, 0x045D, 0x0418},
564     {0x040E, 0x045E, 0x0423}, {0x040F, 0x045F, 0x040F},
565     {0x0410, 0x0430, 0x0410}, {0x0411, 0x0431, 0x0411},
566     {0x0412, 0x0432, 0x0412}, {0x0413, 0x0433, 0x0413},
567     {0x0414, 0x0434, 0x0414}, {0x0415, 0x0435, 0x0415},
568     {0x0416, 0x0436, 0x0416}, {0x0417, 0x0437, 0x0417},
569     {0x0418, 0x0438, 0x0418}, {0x0419, 0x0439, 0x0418},
570     {0x041A, 0x043A, 0x041A}, {0x041B, 0x043B, 0x041B},
571     {0x041C, 0x043C, 0x041C}, {0x041D, 0x043D, 0x041D},
572     {0x041E, 0x043E, 0x041E}, {0x041F, 0x043F, 0x041F},
573     {0x0420, 0x0440, 0x0420}, {0x0421, 0x0441, 0x0421},
574     {0x0422, 0x0442, 0x0422}, {0x0423, 0x0443, 0x0423},
575     {0x0424, 0x0444, 0x0424}, {0x0425, 0x0445, 0x0425},
576     {0x0426, 0x0446, 0x0426}, {0x0427, 0x0447, 0x0427},
577     {0x0428, 0x0448, 0x0428}, {0x0429, 0x0449, 0x0429},
578     {0x042A, 0x044A, 0x042A}, {0x042B, 0x044B, 0x042B},
579     {0x042C, 0x044C, 0x042C}, {0x042D, 0x044D, 0x042D},
580     {0x042E, 0x044E, 0x042E}, {0x042F, 0x044F, 0x042F},
581     {0x0410, 0x0430, 0x0410}, {0x0411, 0x0431, 0x0411},
582     {0x0412, 0x0432, 0x0412}, {0x0413, 0x0433, 0x0413},
583     {0x0414, 0x0434, 0x0414}, {0x0415, 0x0435, 0x0415},
584     {0x0416, 0x0436, 0x0416}, {0x0417, 0x0437, 0x0417},
585     {0x0418, 0x0438, 0x0418}, {0x0419, 0x0439, 0x0418},
586     {0x041A, 0x043A, 0x041A}, {0x041B, 0x043B, 0x041B},
587     {0x041C, 0x043C, 0x041C}, {0x041D, 0x043D, 0x041D},
588     {0x041E, 0x043E, 0x041E}, {0x041F, 0x043F, 0x041F},
589     {0x0420, 0x0440, 0x0420}, {0x0421, 0x0441, 0x0421},
590     {0x0422, 0x0442, 0x0422}, {0x0423, 0x0443, 0x0423},
591     {0x0424, 0x0444, 0x0424}, {0x0425, 0x0445, 0x0425},
592     {0x0426, 0x0446, 0x0426}, {0x0427, 0x0447, 0x0427},
593     {0x0428, 0x0448, 0x0428}, {0x0429, 0x0449, 0x0429},
594     {0x042A, 0x044A, 0x042A}, {0x042B, 0x044B, 0x042B},
595     {0x042C, 0x044C, 0x042C}, {0x042D, 0x044D, 0x042D},
596     {0x042E, 0x044E, 0x042E}, {0x042F, 0x044F, 0x042F},
597     {0x0400, 0x0450, 0x0415}, {0x0401, 0x0451, 0x0415},
598     {0x0402, 0x0452, 0x0402}, {0x0403, 0x0453, 0x0413},
599     {0x0404, 0x0454, 0x0404}, {0x0405, 0x0455, 0x0405},
600     {0x0406, 0x0456, 0x0406}, {0x0407, 0x0457, 0x0406},
601     {0x0408, 0x0458, 0x0408}, {0x0409, 0x0459, 0x0409},
602     {0x040A, 0x045A, 0x040A}, {0x040B, 0x045B, 0x040B},
603     {0x040C, 0x045C, 0x041A}, {0x040D, 0x045D, 0x0418},
604     {0x040E, 0x045E, 0x0423}, {0x040F, 0x045F, 0x040F},
605     {0x0460, 0x0461, 0x0460}, {0x0460, 0x0461, 0x0460},
606     {0x0462, 0x0463, 0x0462}, {0x0462, 0x0463, 0x0462},
607     {0x0464, 0x0465, 0x0464}, {0x0464, 0x0465, 0x0464},
608     {0x0466, 0x0467, 0x0466}, {0x0466, 0x0467, 0x0466},
609     {0x0468, 0x0469, 0x0468}, {0x0468, 0x0469, 0x0468},
610     {0x046A, 0x046B, 0x046A}, {0x046A, 0x046B, 0x046A},
611     {0x046C, 0x046D, 0x046C}, {0x046C, 0x046D, 0x046C},
612     {0x046E, 0x046F, 0x046E}, {0x046E, 0x046F, 0x046E},
613     {0x0470, 0x0471, 0x0470}, {0x0470, 0x0471, 0x0470},
614     {0x0472, 0x0473, 0x0472}, {0x0472, 0x0473, 0x0472},
615     {0x0474, 0x0475, 0x0474}, {0x0474, 0x0475, 0x0474},
616     {0x0476, 0x0477, 0x0474}, {0x0476, 0x0477, 0x0474},
617     {0x0478, 0x0479, 0x0478}, {0x0478, 0x0479, 0x0478},
618     {0x047A, 0x047B, 0x047A}, {0x047A, 0x047B, 0x047A},
619     {0x047C, 0x047D, 0x047C}, {0x047C, 0x047D, 0x047C},
620     {0x047E, 0x047F, 0x047E}, {0x047E, 0x047F, 0x047E},
621     {0x0480, 0x0481, 0x0480}, {0x0480, 0x0481, 0x0480},
622     {0x0482, 0x0482, 0x0482}, {0x0483, 0x0483, 0x0483},
623     {0x0484, 0x0484, 0x0484}, {0x0485, 0x0485, 0x0485},
624     {0x0486, 0x0486, 0x0486}, {0x0487, 0x0487, 0x0487},
625     {0x0488, 0x0488, 0x0488}, {0x0489, 0x0489, 0x0489},
626     {0x048A, 0x048A, 0x048A}, {0x048B, 0x048B, 0x048B},
627     {0x048C, 0x048D, 0x048C}, {0x048C, 0x048D, 0x048C},
628     {0x048E, 0x048F, 0x048E}, {0x048E, 0x048F, 0x048E},
629     {0x0490, 0x0491, 0x0490}, {0x0490, 0x0491, 0x0490},
630     {0x0492, 0x0493, 0x0492}, {0x0492, 0x0493, 0x0492},
631     {0x0494, 0x0495, 0x0494}, {0x0494, 0x0495, 0x0494},
632     {0x0496, 0x0497, 0x0496}, {0x0496, 0x0497, 0x0496},
633     {0x0498, 0x0499, 0x0498}, {0x0498, 0x0499, 0x0498},
634     {0x049A, 0x049B, 0x049A}, {0x049A, 0x049B, 0x049A},
635     {0x049C, 0x049D, 0x049C}, {0x049C, 0x049D, 0x049C},
636     {0x049E, 0x049F, 0x049E}, {0x049E, 0x049F, 0x049E},
637     {0x04A0, 0x04A1, 0x04A0}, {0x04A0, 0x04A1, 0x04A0},
638     {0x04A2, 0x04A3, 0x04A2}, {0x04A2, 0x04A3, 0x04A2},
639     {0x04A4, 0x04A5, 0x04A4}, {0x04A4, 0x04A5, 0x04A4},
640     {0x04A6, 0x04A7, 0x04A6}, {0x04A6, 0x04A7, 0x04A6},
641     {0x04A8, 0x04A9, 0x04A8}, {0x04A8, 0x04A9, 0x04A8},
642     {0x04AA, 0x04AB, 0x04AA}, {0x04AA, 0x04AB, 0x04AA},
643     {0x04AC, 0x04AD, 0x04AC}, {0x04AC, 0x04AD, 0x04AC},
644     {0x04AE, 0x04AF, 0x04AE}, {0x04AE, 0x04AF, 0x04AE},
645     {0x04B0, 0x04B1, 0x04B0}, {0x04B0, 0x04B1, 0x04B0},
646     {0x04B2, 0x04B3, 0x04B2}, {0x04B2, 0x04B3, 0x04B2},
647     {0x04B4, 0x04B5, 0x04B4}, {0x04B4, 0x04B5, 0x04B4},
648     {0x04B6, 0x04B7, 0x04B6}, {0x04B6, 0x04B7, 0x04B6},
649     {0x04B8, 0x04B9, 0x04B8}, {0x04B8, 0x04B9, 0x04B8},
650     {0x04BA, 0x04BB, 0x04BA}, {0x04BA, 0x04BB, 0x04BA},
651     {0x04BC, 0x04BD, 0x04BC}, {0x04BC, 0x04BD, 0x04BC},
652     {0x04BE, 0x04BF, 0x04BE}, {0x04BE, 0x04BF, 0x04BE},
653     {0x04C0, 0x04C0, 0x04C0}, {0x04C1, 0x04C2, 0x0416},
654     {0x04C1, 0x04C2, 0x0416}, {0x04C3, 0x04C4, 0x04C3},
655     {0x04C3, 0x04C4, 0x04C3}, {0x04C5, 0x04C5, 0x04C5},
656     {0x04C6, 0x04C6, 0x04C6}, {0x04C7, 0x04C8, 0x04C7},
657     {0x04C7, 0x04C8, 0x04C7}, {0x04C9, 0x04C9, 0x04C9},
658     {0x04CA, 0x04CA, 0x04CA}, {0x04CB, 0x04CC, 0x04CB},
659     {0x04CB, 0x04CC, 0x04CB}, {0x04CD, 0x04CD, 0x04CD},
660     {0x04CE, 0x04CE, 0x04CE}, {0x04CF, 0x04CF, 0x04CF},
661     {0x04D0, 0x04D1, 0x0410}, {0x04D0, 0x04D1, 0x0410},
662     {0x04D2, 0x04D3, 0x0410}, {0x04D2, 0x04D3, 0x0410},
663     {0x04D4, 0x04D5, 0x04D4}, {0x04D4, 0x04D5, 0x04D4},
664     {0x04D6, 0x04D7, 0x0415}, {0x04D6, 0x04D7, 0x0415},
665     {0x04D8, 0x04D9, 0x04D8}, {0x04D8, 0x04D9, 0x04D8},
666     {0x04DA, 0x04DB, 0x04D8}, {0x04DA, 0x04DB, 0x04D8},
667     {0x04DC, 0x04DD, 0x0416}, {0x04DC, 0x04DD, 0x0416},
668     {0x04DE, 0x04DF, 0x0417}, {0x04DE, 0x04DF, 0x0417},
669     {0x04E0, 0x04E1, 0x04E0}, {0x04E0, 0x04E1, 0x04E0},
670     {0x04E2, 0x04E3, 0x0418}, {0x04E2, 0x04E3, 0x0418},
671     {0x04E4, 0x04E5, 0x0418}, {0x04E4, 0x04E5, 0x0418},
672     {0x04E6, 0x04E7, 0x041E}, {0x04E6, 0x04E7, 0x041E},
673     {0x04E8, 0x04E9, 0x04E8}, {0x04E8, 0x04E9, 0x04E8},
674     {0x04EA, 0x04EB, 0x04E8}, {0x04EA, 0x04EB, 0x04E8},
675     {0x04EC, 0x04ED, 0x042D}, {0x04EC, 0x04ED, 0x042D},
676     {0x04EE, 0x04EF, 0x0423}, {0x04EE, 0x04EF, 0x0423},
677     {0x04F0, 0x04F1, 0x0423}, {0x04F0, 0x04F1, 0x0423},
678     {0x04F2, 0x04F3, 0x0423}, {0x04F2, 0x04F3, 0x0423},
679     {0x04F4, 0x04F5, 0x0427}, {0x04F4, 0x04F5, 0x0427},
680     {0x04F6, 0x04F6, 0x04F6}, {0x04F7, 0x04F7, 0x04F7},
681     {0x04F8, 0x04F9, 0x042B}, {0x04F8, 0x04F9, 0x042B},
682     {0x04FA, 0x04FA, 0x04FA}, {0x04FB, 0x04FB, 0x04FB},
683     {0x04FC, 0x04FC, 0x04FC}, {0x04FD, 0x04FD, 0x04FD},
684     {0x04FE, 0x04FE, 0x04FE}, {0x04FF, 0x04FF, 0x04FF}
685 };
686 
687 static MY_UNICASE_INFO plane05[] = {
688     {0x0500, 0x0500, 0x0500}, {0x0501, 0x0501, 0x0501},
689     {0x0502, 0x0502, 0x0502}, {0x0503, 0x0503, 0x0503},
690     {0x0504, 0x0504, 0x0504}, {0x0505, 0x0505, 0x0505},
691     {0x0506, 0x0506, 0x0506}, {0x0507, 0x0507, 0x0507},
692     {0x0508, 0x0508, 0x0508}, {0x0509, 0x0509, 0x0509},
693     {0x050A, 0x050A, 0x050A}, {0x050B, 0x050B, 0x050B},
694     {0x050C, 0x050C, 0x050C}, {0x050D, 0x050D, 0x050D},
695     {0x050E, 0x050E, 0x050E}, {0x050F, 0x050F, 0x050F},
696     {0x0510, 0x0510, 0x0510}, {0x0511, 0x0511, 0x0511},
697     {0x0512, 0x0512, 0x0512}, {0x0513, 0x0513, 0x0513},
698     {0x0514, 0x0514, 0x0514}, {0x0515, 0x0515, 0x0515},
699     {0x0516, 0x0516, 0x0516}, {0x0517, 0x0517, 0x0517},
700     {0x0518, 0x0518, 0x0518}, {0x0519, 0x0519, 0x0519},
701     {0x051A, 0x051A, 0x051A}, {0x051B, 0x051B, 0x051B},
702     {0x051C, 0x051C, 0x051C}, {0x051D, 0x051D, 0x051D},
703     {0x051E, 0x051E, 0x051E}, {0x051F, 0x051F, 0x051F},
704     {0x0520, 0x0520, 0x0520}, {0x0521, 0x0521, 0x0521},
705     {0x0522, 0x0522, 0x0522}, {0x0523, 0x0523, 0x0523},
706     {0x0524, 0x0524, 0x0524}, {0x0525, 0x0525, 0x0525},
707     {0x0526, 0x0526, 0x0526}, {0x0527, 0x0527, 0x0527},
708     {0x0528, 0x0528, 0x0528}, {0x0529, 0x0529, 0x0529},
709     {0x052A, 0x052A, 0x052A}, {0x052B, 0x052B, 0x052B},
710     {0x052C, 0x052C, 0x052C}, {0x052D, 0x052D, 0x052D},
711     {0x052E, 0x052E, 0x052E}, {0x052F, 0x052F, 0x052F},
712     {0x0530, 0x0530, 0x0530}, {0x0531, 0x0561, 0x0531},
713     {0x0532, 0x0562, 0x0532}, {0x0533, 0x0563, 0x0533},
714     {0x0534, 0x0564, 0x0534}, {0x0535, 0x0565, 0x0535},
715     {0x0536, 0x0566, 0x0536}, {0x0537, 0x0567, 0x0537},
716     {0x0538, 0x0568, 0x0538}, {0x0539, 0x0569, 0x0539},
717     {0x053A, 0x056A, 0x053A}, {0x053B, 0x056B, 0x053B},
718     {0x053C, 0x056C, 0x053C}, {0x053D, 0x056D, 0x053D},
719     {0x053E, 0x056E, 0x053E}, {0x053F, 0x056F, 0x053F},
720     {0x0540, 0x0570, 0x0540}, {0x0541, 0x0571, 0x0541},
721     {0x0542, 0x0572, 0x0542}, {0x0543, 0x0573, 0x0543},
722     {0x0544, 0x0574, 0x0544}, {0x0545, 0x0575, 0x0545},
723     {0x0546, 0x0576, 0x0546}, {0x0547, 0x0577, 0x0547},
724     {0x0548, 0x0578, 0x0548}, {0x0549, 0x0579, 0x0549},
725     {0x054A, 0x057A, 0x054A}, {0x054B, 0x057B, 0x054B},
726     {0x054C, 0x057C, 0x054C}, {0x054D, 0x057D, 0x054D},
727     {0x054E, 0x057E, 0x054E}, {0x054F, 0x057F, 0x054F},
728     {0x0550, 0x0580, 0x0550}, {0x0551, 0x0581, 0x0551},
729     {0x0552, 0x0582, 0x0552}, {0x0553, 0x0583, 0x0553},
730     {0x0554, 0x0584, 0x0554}, {0x0555, 0x0585, 0x0555},
731     {0x0556, 0x0586, 0x0556}, {0x0557, 0x0557, 0x0557},
732     {0x0558, 0x0558, 0x0558}, {0x0559, 0x0559, 0x0559},
733     {0x055A, 0x055A, 0x055A}, {0x055B, 0x055B, 0x055B},
734     {0x055C, 0x055C, 0x055C}, {0x055D, 0x055D, 0x055D},
735     {0x055E, 0x055E, 0x055E}, {0x055F, 0x055F, 0x055F},
736     {0x0560, 0x0560, 0x0560}, {0x0531, 0x0561, 0x0531},
737     {0x0532, 0x0562, 0x0532}, {0x0533, 0x0563, 0x0533},
738     {0x0534, 0x0564, 0x0534}, {0x0535, 0x0565, 0x0535},
739     {0x0536, 0x0566, 0x0536}, {0x0537, 0x0567, 0x0537},
740     {0x0538, 0x0568, 0x0538}, {0x0539, 0x0569, 0x0539},
741     {0x053A, 0x056A, 0x053A}, {0x053B, 0x056B, 0x053B},
742     {0x053C, 0x056C, 0x053C}, {0x053D, 0x056D, 0x053D},
743     {0x053E, 0x056E, 0x053E}, {0x053F, 0x056F, 0x053F},
744     {0x0540, 0x0570, 0x0540}, {0x0541, 0x0571, 0x0541},
745     {0x0542, 0x0572, 0x0542}, {0x0543, 0x0573, 0x0543},
746     {0x0544, 0x0574, 0x0544}, {0x0545, 0x0575, 0x0545},
747     {0x0546, 0x0576, 0x0546}, {0x0547, 0x0577, 0x0547},
748     {0x0548, 0x0578, 0x0548}, {0x0549, 0x0579, 0x0549},
749     {0x054A, 0x057A, 0x054A}, {0x054B, 0x057B, 0x054B},
750     {0x054C, 0x057C, 0x054C}, {0x054D, 0x057D, 0x054D},
751     {0x054E, 0x057E, 0x054E}, {0x054F, 0x057F, 0x054F},
752     {0x0550, 0x0580, 0x0550}, {0x0551, 0x0581, 0x0551},
753     {0x0552, 0x0582, 0x0552}, {0x0553, 0x0583, 0x0553},
754     {0x0554, 0x0584, 0x0554}, {0x0555, 0x0585, 0x0555},
755     {0x0556, 0x0586, 0x0556}, {0x0587, 0x0587, 0x0587},
756     {0x0588, 0x0588, 0x0588}, {0x0589, 0x0589, 0x0589},
757     {0x058A, 0x058A, 0x058A}, {0x058B, 0x058B, 0x058B},
758     {0x058C, 0x058C, 0x058C}, {0x058D, 0x058D, 0x058D},
759     {0x058E, 0x058E, 0x058E}, {0x058F, 0x058F, 0x058F},
760     {0x0590, 0x0590, 0x0590}, {0x0591, 0x0591, 0x0591},
761     {0x0592, 0x0592, 0x0592}, {0x0593, 0x0593, 0x0593},
762     {0x0594, 0x0594, 0x0594}, {0x0595, 0x0595, 0x0595},
763     {0x0596, 0x0596, 0x0596}, {0x0597, 0x0597, 0x0597},
764     {0x0598, 0x0598, 0x0598}, {0x0599, 0x0599, 0x0599},
765     {0x059A, 0x059A, 0x059A}, {0x059B, 0x059B, 0x059B},
766     {0x059C, 0x059C, 0x059C}, {0x059D, 0x059D, 0x059D},
767     {0x059E, 0x059E, 0x059E}, {0x059F, 0x059F, 0x059F},
768     {0x05A0, 0x05A0, 0x05A0}, {0x05A1, 0x05A1, 0x05A1},
769     {0x05A2, 0x05A2, 0x05A2}, {0x05A3, 0x05A3, 0x05A3},
770     {0x05A4, 0x05A4, 0x05A4}, {0x05A5, 0x05A5, 0x05A5},
771     {0x05A6, 0x05A6, 0x05A6}, {0x05A7, 0x05A7, 0x05A7},
772     {0x05A8, 0x05A8, 0x05A8}, {0x05A9, 0x05A9, 0x05A9},
773     {0x05AA, 0x05AA, 0x05AA}, {0x05AB, 0x05AB, 0x05AB},
774     {0x05AC, 0x05AC, 0x05AC}, {0x05AD, 0x05AD, 0x05AD},
775     {0x05AE, 0x05AE, 0x05AE}, {0x05AF, 0x05AF, 0x05AF},
776     {0x05B0, 0x05B0, 0x05B0}, {0x05B1, 0x05B1, 0x05B1},
777     {0x05B2, 0x05B2, 0x05B2}, {0x05B3, 0x05B3, 0x05B3},
778     {0x05B4, 0x05B4, 0x05B4}, {0x05B5, 0x05B5, 0x05B5},
779     {0x05B6, 0x05B6, 0x05B6}, {0x05B7, 0x05B7, 0x05B7},
780     {0x05B8, 0x05B8, 0x05B8}, {0x05B9, 0x05B9, 0x05B9},
781     {0x05BA, 0x05BA, 0x05BA}, {0x05BB, 0x05BB, 0x05BB},
782     {0x05BC, 0x05BC, 0x05BC}, {0x05BD, 0x05BD, 0x05BD},
783     {0x05BE, 0x05BE, 0x05BE}, {0x05BF, 0x05BF, 0x05BF},
784     {0x05C0, 0x05C0, 0x05C0}, {0x05C1, 0x05C1, 0x05C1},
785     {0x05C2, 0x05C2, 0x05C2}, {0x05C3, 0x05C3, 0x05C3},
786     {0x05C4, 0x05C4, 0x05C4}, {0x05C5, 0x05C5, 0x05C5},
787     {0x05C6, 0x05C6, 0x05C6}, {0x05C7, 0x05C7, 0x05C7},
788     {0x05C8, 0x05C8, 0x05C8}, {0x05C9, 0x05C9, 0x05C9},
789     {0x05CA, 0x05CA, 0x05CA}, {0x05CB, 0x05CB, 0x05CB},
790     {0x05CC, 0x05CC, 0x05CC}, {0x05CD, 0x05CD, 0x05CD},
791     {0x05CE, 0x05CE, 0x05CE}, {0x05CF, 0x05CF, 0x05CF},
792     {0x05D0, 0x05D0, 0x05D0}, {0x05D1, 0x05D1, 0x05D1},
793     {0x05D2, 0x05D2, 0x05D2}, {0x05D3, 0x05D3, 0x05D3},
794     {0x05D4, 0x05D4, 0x05D4}, {0x05D5, 0x05D5, 0x05D5},
795     {0x05D6, 0x05D6, 0x05D6}, {0x05D7, 0x05D7, 0x05D7},
796     {0x05D8, 0x05D8, 0x05D8}, {0x05D9, 0x05D9, 0x05D9},
797     {0x05DA, 0x05DA, 0x05DA}, {0x05DB, 0x05DB, 0x05DB},
798     {0x05DC, 0x05DC, 0x05DC}, {0x05DD, 0x05DD, 0x05DD},
799     {0x05DE, 0x05DE, 0x05DE}, {0x05DF, 0x05DF, 0x05DF},
800     {0x05E0, 0x05E0, 0x05E0}, {0x05E1, 0x05E1, 0x05E1},
801     {0x05E2, 0x05E2, 0x05E2}, {0x05E3, 0x05E3, 0x05E3},
802     {0x05E4, 0x05E4, 0x05E4}, {0x05E5, 0x05E5, 0x05E5},
803     {0x05E6, 0x05E6, 0x05E6}, {0x05E7, 0x05E7, 0x05E7},
804     {0x05E8, 0x05E8, 0x05E8}, {0x05E9, 0x05E9, 0x05E9},
805     {0x05EA, 0x05EA, 0x05EA}, {0x05EB, 0x05EB, 0x05EB},
806     {0x05EC, 0x05EC, 0x05EC}, {0x05ED, 0x05ED, 0x05ED},
807     {0x05EE, 0x05EE, 0x05EE}, {0x05EF, 0x05EF, 0x05EF},
808     {0x05F0, 0x05F0, 0x05F0}, {0x05F1, 0x05F1, 0x05F1},
809     {0x05F2, 0x05F2, 0x05F2}, {0x05F3, 0x05F3, 0x05F3},
810     {0x05F4, 0x05F4, 0x05F4}, {0x05F5, 0x05F5, 0x05F5},
811     {0x05F6, 0x05F6, 0x05F6}, {0x05F7, 0x05F7, 0x05F7},
812     {0x05F8, 0x05F8, 0x05F8}, {0x05F9, 0x05F9, 0x05F9},
813     {0x05FA, 0x05FA, 0x05FA}, {0x05FB, 0x05FB, 0x05FB},
814     {0x05FC, 0x05FC, 0x05FC}, {0x05FD, 0x05FD, 0x05FD},
815     {0x05FE, 0x05FE, 0x05FE}, {0x05FF, 0x05FF, 0x05FF}
816 };
817 
818 static MY_UNICASE_INFO plane1E[] = {
819     {0x1E00, 0x1E01, 0x0041}, {0x1E00, 0x1E01, 0x0041},
820     {0x1E02, 0x1E03, 0x0042}, {0x1E02, 0x1E03, 0x0042},
821     {0x1E04, 0x1E05, 0x0042}, {0x1E04, 0x1E05, 0x0042},
822     {0x1E06, 0x1E07, 0x0042}, {0x1E06, 0x1E07, 0x0042},
823     {0x1E08, 0x1E09, 0x0043}, {0x1E08, 0x1E09, 0x0043},
824     {0x1E0A, 0x1E0B, 0x0044}, {0x1E0A, 0x1E0B, 0x0044},
825     {0x1E0C, 0x1E0D, 0x0044}, {0x1E0C, 0x1E0D, 0x0044},
826     {0x1E0E, 0x1E0F, 0x0044}, {0x1E0E, 0x1E0F, 0x0044},
827     {0x1E10, 0x1E11, 0x0044}, {0x1E10, 0x1E11, 0x0044},
828     {0x1E12, 0x1E13, 0x0044}, {0x1E12, 0x1E13, 0x0044},
829     {0x1E14, 0x1E15, 0x0045}, {0x1E14, 0x1E15, 0x0045},
830     {0x1E16, 0x1E17, 0x0045}, {0x1E16, 0x1E17, 0x0045},
831     {0x1E18, 0x1E19, 0x0045}, {0x1E18, 0x1E19, 0x0045},
832     {0x1E1A, 0x1E1B, 0x0045}, {0x1E1A, 0x1E1B, 0x0045},
833     {0x1E1C, 0x1E1D, 0x0045}, {0x1E1C, 0x1E1D, 0x0045},
834     {0x1E1E, 0x1E1F, 0x0046}, {0x1E1E, 0x1E1F, 0x0046},
835     {0x1E20, 0x1E21, 0x0047}, {0x1E20, 0x1E21, 0x0047},
836     {0x1E22, 0x1E23, 0x0048}, {0x1E22, 0x1E23, 0x0048},
837     {0x1E24, 0x1E25, 0x0048}, {0x1E24, 0x1E25, 0x0048},
838     {0x1E26, 0x1E27, 0x0048}, {0x1E26, 0x1E27, 0x0048},
839     {0x1E28, 0x1E29, 0x0048}, {0x1E28, 0x1E29, 0x0048},
840     {0x1E2A, 0x1E2B, 0x0048}, {0x1E2A, 0x1E2B, 0x0048},
841     {0x1E2C, 0x1E2D, 0x0049}, {0x1E2C, 0x1E2D, 0x0049},
842     {0x1E2E, 0x1E2F, 0x0049}, {0x1E2E, 0x1E2F, 0x0049},
843     {0x1E30, 0x1E31, 0x004B}, {0x1E30, 0x1E31, 0x004B},
844     {0x1E32, 0x1E33, 0x004B}, {0x1E32, 0x1E33, 0x004B},
845     {0x1E34, 0x1E35, 0x004B}, {0x1E34, 0x1E35, 0x004B},
846     {0x1E36, 0x1E37, 0x004C}, {0x1E36, 0x1E37, 0x004C},
847     {0x1E38, 0x1E39, 0x004C}, {0x1E38, 0x1E39, 0x004C},
848     {0x1E3A, 0x1E3B, 0x004C}, {0x1E3A, 0x1E3B, 0x004C},
849     {0x1E3C, 0x1E3D, 0x004C}, {0x1E3C, 0x1E3D, 0x004C},
850     {0x1E3E, 0x1E3F, 0x004D}, {0x1E3E, 0x1E3F, 0x004D},
851     {0x1E40, 0x1E41, 0x004D}, {0x1E40, 0x1E41, 0x004D},
852     {0x1E42, 0x1E43, 0x004D}, {0x1E42, 0x1E43, 0x004D},
853     {0x1E44, 0x1E45, 0x004E}, {0x1E44, 0x1E45, 0x004E},
854     {0x1E46, 0x1E47, 0x004E}, {0x1E46, 0x1E47, 0x004E},
855     {0x1E48, 0x1E49, 0x004E}, {0x1E48, 0x1E49, 0x004E},
856     {0x1E4A, 0x1E4B, 0x004E}, {0x1E4A, 0x1E4B, 0x004E},
857     {0x1E4C, 0x1E4D, 0x004F}, {0x1E4C, 0x1E4D, 0x004F},
858     {0x1E4E, 0x1E4F, 0x004F}, {0x1E4E, 0x1E4F, 0x004F},
859     {0x1E50, 0x1E51, 0x004F}, {0x1E50, 0x1E51, 0x004F},
860     {0x1E52, 0x1E53, 0x004F}, {0x1E52, 0x1E53, 0x004F},
861     {0x1E54, 0x1E55, 0x0050}, {0x1E54, 0x1E55, 0x0050},
862     {0x1E56, 0x1E57, 0x0050}, {0x1E56, 0x1E57, 0x0050},
863     {0x1E58, 0x1E59, 0x0052}, {0x1E58, 0x1E59, 0x0052},
864     {0x1E5A, 0x1E5B, 0x0052}, {0x1E5A, 0x1E5B, 0x0052},
865     {0x1E5C, 0x1E5D, 0x0052}, {0x1E5C, 0x1E5D, 0x0052},
866     {0x1E5E, 0x1E5F, 0x0052}, {0x1E5E, 0x1E5F, 0x0052},
867     {0x1E60, 0x1E61, 0x0053}, {0x1E60, 0x1E61, 0x0053},
868     {0x1E62, 0x1E63, 0x0053}, {0x1E62, 0x1E63, 0x0053},
869     {0x1E64, 0x1E65, 0x0053}, {0x1E64, 0x1E65, 0x0053},
870     {0x1E66, 0x1E67, 0x0053}, {0x1E66, 0x1E67, 0x0053},
871     {0x1E68, 0x1E69, 0x0053}, {0x1E68, 0x1E69, 0x0053},
872     {0x1E6A, 0x1E6B, 0x0054}, {0x1E6A, 0x1E6B, 0x0054},
873     {0x1E6C, 0x1E6D, 0x0054}, {0x1E6C, 0x1E6D, 0x0054},
874     {0x1E6E, 0x1E6F, 0x0054}, {0x1E6E, 0x1E6F, 0x0054},
875     {0x1E70, 0x1E71, 0x0054}, {0x1E70, 0x1E71, 0x0054},
876     {0x1E72, 0x1E73, 0x0055}, {0x1E72, 0x1E73, 0x0055},
877     {0x1E74, 0x1E75, 0x0055}, {0x1E74, 0x1E75, 0x0055},
878     {0x1E76, 0x1E77, 0x0055}, {0x1E76, 0x1E77, 0x0055},
879     {0x1E78, 0x1E79, 0x0055}, {0x1E78, 0x1E79, 0x0055},
880     {0x1E7A, 0x1E7B, 0x0055}, {0x1E7A, 0x1E7B, 0x0055},
881     {0x1E7C, 0x1E7D, 0x0056}, {0x1E7C, 0x1E7D, 0x0056},
882     {0x1E7E, 0x1E7F, 0x0056}, {0x1E7E, 0x1E7F, 0x0056},
883     {0x1E80, 0x1E81, 0x0057}, {0x1E80, 0x1E81, 0x0057},
884     {0x1E82, 0x1E83, 0x0057}, {0x1E82, 0x1E83, 0x0057},
885     {0x1E84, 0x1E85, 0x0057}, {0x1E84, 0x1E85, 0x0057},
886     {0x1E86, 0x1E87, 0x0057}, {0x1E86, 0x1E87, 0x0057},
887     {0x1E88, 0x1E89, 0x0057}, {0x1E88, 0x1E89, 0x0057},
888     {0x1E8A, 0x1E8B, 0x0058}, {0x1E8A, 0x1E8B, 0x0058},
889     {0x1E8C, 0x1E8D, 0x0058}, {0x1E8C, 0x1E8D, 0x0058},
890     {0x1E8E, 0x1E8F, 0x0059}, {0x1E8E, 0x1E8F, 0x0059},
891     {0x1E90, 0x1E91, 0x005A}, {0x1E90, 0x1E91, 0x005A},
892     {0x1E92, 0x1E93, 0x005A}, {0x1E92, 0x1E93, 0x005A},
893     {0x1E94, 0x1E95, 0x005A}, {0x1E94, 0x1E95, 0x005A},
894     {0x1E96, 0x1E96, 0x0048}, {0x1E97, 0x1E97, 0x0054},
895     {0x1E98, 0x1E98, 0x0057}, {0x1E99, 0x1E99, 0x0059},
896     {0x1E9A, 0x1E9A, 0x1E9A}, {0x1E60, 0x1E9B, 0x0053},
897     {0x1E9C, 0x1E9C, 0x1E9C}, {0x1E9D, 0x1E9D, 0x1E9D},
898     {0x1E9E, 0x1E9E, 0x1E9E}, {0x1E9F, 0x1E9F, 0x1E9F},
899     {0x1EA0, 0x1EA1, 0x0041}, {0x1EA0, 0x1EA1, 0x0041},
900     {0x1EA2, 0x1EA3, 0x0041}, {0x1EA2, 0x1EA3, 0x0041},
901     {0x1EA4, 0x1EA5, 0x0041}, {0x1EA4, 0x1EA5, 0x0041},
902     {0x1EA6, 0x1EA7, 0x0041}, {0x1EA6, 0x1EA7, 0x0041},
903     {0x1EA8, 0x1EA9, 0x0041}, {0x1EA8, 0x1EA9, 0x0041},
904     {0x1EAA, 0x1EAB, 0x0041}, {0x1EAA, 0x1EAB, 0x0041},
905     {0x1EAC, 0x1EAD, 0x0041}, {0x1EAC, 0x1EAD, 0x0041},
906     {0x1EAE, 0x1EAF, 0x0041}, {0x1EAE, 0x1EAF, 0x0041},
907     {0x1EB0, 0x1EB1, 0x0041}, {0x1EB0, 0x1EB1, 0x0041},
908     {0x1EB2, 0x1EB3, 0x0041}, {0x1EB2, 0x1EB3, 0x0041},
909     {0x1EB4, 0x1EB5, 0x0041}, {0x1EB4, 0x1EB5, 0x0041},
910     {0x1EB6, 0x1EB7, 0x0041}, {0x1EB6, 0x1EB7, 0x0041},
911     {0x1EB8, 0x1EB9, 0x0045}, {0x1EB8, 0x1EB9, 0x0045},
912     {0x1EBA, 0x1EBB, 0x0045}, {0x1EBA, 0x1EBB, 0x0045},
913     {0x1EBC, 0x1EBD, 0x0045}, {0x1EBC, 0x1EBD, 0x0045},
914     {0x1EBE, 0x1EBF, 0x0045}, {0x1EBE, 0x1EBF, 0x0045},
915     {0x1EC0, 0x1EC1, 0x0045}, {0x1EC0, 0x1EC1, 0x0045},
916     {0x1EC2, 0x1EC3, 0x0045}, {0x1EC2, 0x1EC3, 0x0045},
917     {0x1EC4, 0x1EC5, 0x0045}, {0x1EC4, 0x1EC5, 0x0045},
918     {0x1EC6, 0x1EC7, 0x0045}, {0x1EC6, 0x1EC7, 0x0045},
919     {0x1EC8, 0x1EC9, 0x0049}, {0x1EC8, 0x1EC9, 0x0049},
920     {0x1ECA, 0x1ECB, 0x0049}, {0x1ECA, 0x1ECB, 0x0049},
921     {0x1ECC, 0x1ECD, 0x004F}, {0x1ECC, 0x1ECD, 0x004F},
922     {0x1ECE, 0x1ECF, 0x004F}, {0x1ECE, 0x1ECF, 0x004F},
923     {0x1ED0, 0x1ED1, 0x004F}, {0x1ED0, 0x1ED1, 0x004F},
924     {0x1ED2, 0x1ED3, 0x004F}, {0x1ED2, 0x1ED3, 0x004F},
925     {0x1ED4, 0x1ED5, 0x004F}, {0x1ED4, 0x1ED5, 0x004F},
926     {0x1ED6, 0x1ED7, 0x004F}, {0x1ED6, 0x1ED7, 0x004F},
927     {0x1ED8, 0x1ED9, 0x004F}, {0x1ED8, 0x1ED9, 0x004F},
928     {0x1EDA, 0x1EDB, 0x004F}, {0x1EDA, 0x1EDB, 0x004F},
929     {0x1EDC, 0x1EDD, 0x004F}, {0x1EDC, 0x1EDD, 0x004F},
930     {0x1EDE, 0x1EDF, 0x004F}, {0x1EDE, 0x1EDF, 0x004F},
931     {0x1EE0, 0x1EE1, 0x004F}, {0x1EE0, 0x1EE1, 0x004F},
932     {0x1EE2, 0x1EE3, 0x004F}, {0x1EE2, 0x1EE3, 0x004F},
933     {0x1EE4, 0x1EE5, 0x0055}, {0x1EE4, 0x1EE5, 0x0055},
934     {0x1EE6, 0x1EE7, 0x0055}, {0x1EE6, 0x1EE7, 0x0055},
935     {0x1EE8, 0x1EE9, 0x0055}, {0x1EE8, 0x1EE9, 0x0055},
936     {0x1EEA, 0x1EEB, 0x0055}, {0x1EEA, 0x1EEB, 0x0055},
937     {0x1EEC, 0x1EED, 0x0055}, {0x1EEC, 0x1EED, 0x0055},
938     {0x1EEE, 0x1EEF, 0x0055}, {0x1EEE, 0x1EEF, 0x0055},
939     {0x1EF0, 0x1EF1, 0x0055}, {0x1EF0, 0x1EF1, 0x0055},
940     {0x1EF2, 0x1EF3, 0x0059}, {0x1EF2, 0x1EF3, 0x0059},
941     {0x1EF4, 0x1EF5, 0x0059}, {0x1EF4, 0x1EF5, 0x0059},
942     {0x1EF6, 0x1EF7, 0x0059}, {0x1EF6, 0x1EF7, 0x0059},
943     {0x1EF8, 0x1EF9, 0x0059}, {0x1EF8, 0x1EF9, 0x0059},
944     {0x1EFA, 0x1EFA, 0x1EFA}, {0x1EFB, 0x1EFB, 0x1EFB},
945     {0x1EFC, 0x1EFC, 0x1EFC}, {0x1EFD, 0x1EFD, 0x1EFD},
946     {0x1EFE, 0x1EFE, 0x1EFE}, {0x1EFF, 0x1EFF, 0x1EFF}
947 };
948 
949 static MY_UNICASE_INFO plane1F[] = {
950     {0x1F08, 0x1F00, 0x0391}, {0x1F09, 0x1F01, 0x0391},
951     {0x1F0A, 0x1F02, 0x0391}, {0x1F0B, 0x1F03, 0x0391},
952     {0x1F0C, 0x1F04, 0x0391}, {0x1F0D, 0x1F05, 0x0391},
953     {0x1F0E, 0x1F06, 0x0391}, {0x1F0F, 0x1F07, 0x0391},
954     {0x1F08, 0x1F00, 0x0391}, {0x1F09, 0x1F01, 0x0391},
955     {0x1F0A, 0x1F02, 0x0391}, {0x1F0B, 0x1F03, 0x0391},
956     {0x1F0C, 0x1F04, 0x0391}, {0x1F0D, 0x1F05, 0x0391},
957     {0x1F0E, 0x1F06, 0x0391}, {0x1F0F, 0x1F07, 0x0391},
958     {0x1F18, 0x1F10, 0x0395}, {0x1F19, 0x1F11, 0x0395},
959     {0x1F1A, 0x1F12, 0x0395}, {0x1F1B, 0x1F13, 0x0395},
960     {0x1F1C, 0x1F14, 0x0395}, {0x1F1D, 0x1F15, 0x0395},
961     {0x1F16, 0x1F16, 0x1F16}, {0x1F17, 0x1F17, 0x1F17},
962     {0x1F18, 0x1F10, 0x0395}, {0x1F19, 0x1F11, 0x0395},
963     {0x1F1A, 0x1F12, 0x0395}, {0x1F1B, 0x1F13, 0x0395},
964     {0x1F1C, 0x1F14, 0x0395}, {0x1F1D, 0x1F15, 0x0395},
965     {0x1F1E, 0x1F1E, 0x1F1E}, {0x1F1F, 0x1F1F, 0x1F1F},
966     {0x1F28, 0x1F20, 0x0397}, {0x1F29, 0x1F21, 0x0397},
967     {0x1F2A, 0x1F22, 0x0397}, {0x1F2B, 0x1F23, 0x0397},
968     {0x1F2C, 0x1F24, 0x0397}, {0x1F2D, 0x1F25, 0x0397},
969     {0x1F2E, 0x1F26, 0x0397}, {0x1F2F, 0x1F27, 0x0397},
970     {0x1F28, 0x1F20, 0x0397}, {0x1F29, 0x1F21, 0x0397},
971     {0x1F2A, 0x1F22, 0x0397}, {0x1F2B, 0x1F23, 0x0397},
972     {0x1F2C, 0x1F24, 0x0397}, {0x1F2D, 0x1F25, 0x0397},
973     {0x1F2E, 0x1F26, 0x0397}, {0x1F2F, 0x1F27, 0x0397},
974     {0x1F38, 0x1F30, 0x0399}, {0x1F39, 0x1F31, 0x0399},
975     {0x1F3A, 0x1F32, 0x0399}, {0x1F3B, 0x1F33, 0x0399},
976     {0x1F3C, 0x1F34, 0x0399}, {0x1F3D, 0x1F35, 0x0399},
977     {0x1F3E, 0x1F36, 0x0399}, {0x1F3F, 0x1F37, 0x0399},
978     {0x1F38, 0x1F30, 0x0399}, {0x1F39, 0x1F31, 0x0399},
979     {0x1F3A, 0x1F32, 0x0399}, {0x1F3B, 0x1F33, 0x0399},
980     {0x1F3C, 0x1F34, 0x0399}, {0x1F3D, 0x1F35, 0x0399},
981     {0x1F3E, 0x1F36, 0x0399}, {0x1F3F, 0x1F37, 0x0399},
982     {0x1F48, 0x1F40, 0x039F}, {0x1F49, 0x1F41, 0x039F},
983     {0x1F4A, 0x1F42, 0x039F}, {0x1F4B, 0x1F43, 0x039F},
984     {0x1F4C, 0x1F44, 0x039F}, {0x1F4D, 0x1F45, 0x039F},
985     {0x1F46, 0x1F46, 0x1F46}, {0x1F47, 0x1F47, 0x1F47},
986     {0x1F48, 0x1F40, 0x039F}, {0x1F49, 0x1F41, 0x039F},
987     {0x1F4A, 0x1F42, 0x039F}, {0x1F4B, 0x1F43, 0x039F},
988     {0x1F4C, 0x1F44, 0x039F}, {0x1F4D, 0x1F45, 0x039F},
989     {0x1F4E, 0x1F4E, 0x1F4E}, {0x1F4F, 0x1F4F, 0x1F4F},
990     {0x1F50, 0x1F50, 0x03A5}, {0x1F59, 0x1F51, 0x03A5},
991     {0x1F52, 0x1F52, 0x03A5}, {0x1F5B, 0x1F53, 0x03A5},
992     {0x1F54, 0x1F54, 0x03A5}, {0x1F5D, 0x1F55, 0x03A5},
993     {0x1F56, 0x1F56, 0x03A5}, {0x1F5F, 0x1F57, 0x03A5},
994     {0x1F58, 0x1F58, 0x1F58}, {0x1F59, 0x1F51, 0x03A5},
995     {0x1F5A, 0x1F5A, 0x1F5A}, {0x1F5B, 0x1F53, 0x03A5},
996     {0x1F5C, 0x1F5C, 0x1F5C}, {0x1F5D, 0x1F55, 0x03A5},
997     {0x1F5E, 0x1F5E, 0x1F5E}, {0x1F5F, 0x1F57, 0x03A5},
998     {0x1F68, 0x1F60, 0x03A9}, {0x1F69, 0x1F61, 0x03A9},
999     {0x1F6A, 0x1F62, 0x03A9}, {0x1F6B, 0x1F63, 0x03A9},
1000     {0x1F6C, 0x1F64, 0x03A9}, {0x1F6D, 0x1F65, 0x03A9},
1001     {0x1F6E, 0x1F66, 0x03A9}, {0x1F6F, 0x1F67, 0x03A9},
1002     {0x1F68, 0x1F60, 0x03A9}, {0x1F69, 0x1F61, 0x03A9},
1003     {0x1F6A, 0x1F62, 0x03A9}, {0x1F6B, 0x1F63, 0x03A9},
1004     {0x1F6C, 0x1F64, 0x03A9}, {0x1F6D, 0x1F65, 0x03A9},
1005     {0x1F6E, 0x1F66, 0x03A9}, {0x1F6F, 0x1F67, 0x03A9},
1006     {0x1FBA, 0x1F70, 0x0391}, {0x1FBB, 0x1F71, 0x1FBB},
1007     {0x1FC8, 0x1F72, 0x0395}, {0x1FC9, 0x1F73, 0x1FC9},
1008     {0x1FCA, 0x1F74, 0x0397}, {0x1FCB, 0x1F75, 0x1FCB},
1009     {0x1FDA, 0x1F76, 0x0399}, {0x1FDB, 0x1F77, 0x1FDB},
1010     {0x1FF8, 0x1F78, 0x039F}, {0x1FF9, 0x1F79, 0x1FF9},
1011     {0x1FEA, 0x1F7A, 0x03A5}, {0x1FEB, 0x1F7B, 0x1FEB},
1012     {0x1FFA, 0x1F7C, 0x03A9}, {0x1FFB, 0x1F7D, 0x1FFB},
1013     {0x1F7E, 0x1F7E, 0x1F7E}, {0x1F7F, 0x1F7F, 0x1F7F},
1014     {0x1F88, 0x1F80, 0x0391}, {0x1F89, 0x1F81, 0x0391},
1015     {0x1F8A, 0x1F82, 0x0391}, {0x1F8B, 0x1F83, 0x0391},
1016     {0x1F8C, 0x1F84, 0x0391}, {0x1F8D, 0x1F85, 0x0391},
1017     {0x1F8E, 0x1F86, 0x0391}, {0x1F8F, 0x1F87, 0x0391},
1018     {0x1F88, 0x1F80, 0x0391}, {0x1F89, 0x1F81, 0x0391},
1019     {0x1F8A, 0x1F82, 0x0391}, {0x1F8B, 0x1F83, 0x0391},
1020     {0x1F8C, 0x1F84, 0x0391}, {0x1F8D, 0x1F85, 0x0391},
1021     {0x1F8E, 0x1F86, 0x0391}, {0x1F8F, 0x1F87, 0x0391},
1022     {0x1F98, 0x1F90, 0x0397}, {0x1F99, 0x1F91, 0x0397},
1023     {0x1F9A, 0x1F92, 0x0397}, {0x1F9B, 0x1F93, 0x0397},
1024     {0x1F9C, 0x1F94, 0x0397}, {0x1F9D, 0x1F95, 0x0397},
1025     {0x1F9E, 0x1F96, 0x0397}, {0x1F9F, 0x1F97, 0x0397},
1026     {0x1F98, 0x1F90, 0x0397}, {0x1F99, 0x1F91, 0x0397},
1027     {0x1F9A, 0x1F92, 0x0397}, {0x1F9B, 0x1F93, 0x0397},
1028     {0x1F9C, 0x1F94, 0x0397}, {0x1F9D, 0x1F95, 0x0397},
1029     {0x1F9E, 0x1F96, 0x0397}, {0x1F9F, 0x1F97, 0x0397},
1030     {0x1FA8, 0x1FA0, 0x03A9}, {0x1FA9, 0x1FA1, 0x03A9},
1031     {0x1FAA, 0x1FA2, 0x03A9}, {0x1FAB, 0x1FA3, 0x03A9},
1032     {0x1FAC, 0x1FA4, 0x03A9}, {0x1FAD, 0x1FA5, 0x03A9},
1033     {0x1FAE, 0x1FA6, 0x03A9}, {0x1FAF, 0x1FA7, 0x03A9},
1034     {0x1FA8, 0x1FA0, 0x03A9}, {0x1FA9, 0x1FA1, 0x03A9},
1035     {0x1FAA, 0x1FA2, 0x03A9}, {0x1FAB, 0x1FA3, 0x03A9},
1036     {0x1FAC, 0x1FA4, 0x03A9}, {0x1FAD, 0x1FA5, 0x03A9},
1037     {0x1FAE, 0x1FA6, 0x03A9}, {0x1FAF, 0x1FA7, 0x03A9},
1038     {0x1FB8, 0x1FB0, 0x0391}, {0x1FB9, 0x1FB1, 0x0391},
1039     {0x1FB2, 0x1FB2, 0x0391}, {0x1FBC, 0x1FB3, 0x0391},
1040     {0x1FB4, 0x1FB4, 0x0391}, {0x1FB5, 0x1FB5, 0x1FB5},
1041     {0x1FB6, 0x1FB6, 0x0391}, {0x1FB7, 0x1FB7, 0x0391},
1042     {0x1FB8, 0x1FB0, 0x0391}, {0x1FB9, 0x1FB1, 0x0391},
1043     {0x1FBA, 0x1F70, 0x0391}, {0x1FBB, 0x1F71, 0x1FBB},
1044     {0x1FBC, 0x1FB3, 0x0391}, {0x1FBD, 0x1FBD, 0x1FBD},
1045     {0x0399, 0x1FBE, 0x0399}, {0x1FBF, 0x1FBF, 0x1FBF},
1046     {0x1FC0, 0x1FC0, 0x1FC0}, {0x1FC1, 0x1FC1, 0x1FC1},
1047     {0x1FC2, 0x1FC2, 0x0397}, {0x1FCC, 0x1FC3, 0x0397},
1048     {0x1FC4, 0x1FC4, 0x0397}, {0x1FC5, 0x1FC5, 0x1FC5},
1049     {0x1FC6, 0x1FC6, 0x0397}, {0x1FC7, 0x1FC7, 0x0397},
1050     {0x1FC8, 0x1F72, 0x0395}, {0x1FC9, 0x1F73, 0x1FC9},
1051     {0x1FCA, 0x1F74, 0x0397}, {0x1FCB, 0x1F75, 0x1FCB},
1052     {0x1FCC, 0x1FC3, 0x0397}, {0x1FCD, 0x1FCD, 0x1FCD},
1053     {0x1FCE, 0x1FCE, 0x1FCE}, {0x1FCF, 0x1FCF, 0x1FCF},
1054     {0x1FD8, 0x1FD0, 0x0399}, {0x1FD9, 0x1FD1, 0x0399},
1055     {0x1FD2, 0x1FD2, 0x0399}, {0x1FD3, 0x1FD3, 0x1FD3},
1056     {0x1FD4, 0x1FD4, 0x1FD4}, {0x1FD5, 0x1FD5, 0x1FD5},
1057     {0x1FD6, 0x1FD6, 0x0399}, {0x1FD7, 0x1FD7, 0x0399},
1058     {0x1FD8, 0x1FD0, 0x0399}, {0x1FD9, 0x1FD1, 0x0399},
1059     {0x1FDA, 0x1F76, 0x0399}, {0x1FDB, 0x1F77, 0x1FDB},
1060     {0x1FDC, 0x1FDC, 0x1FDC}, {0x1FDD, 0x1FDD, 0x1FDD},
1061     {0x1FDE, 0x1FDE, 0x1FDE}, {0x1FDF, 0x1FDF, 0x1FDF},
1062     {0x1FE8, 0x1FE0, 0x03A5}, {0x1FE9, 0x1FE1, 0x03A5},
1063     {0x1FE2, 0x1FE2, 0x03A5}, {0x1FE3, 0x1FE3, 0x1FE3},
1064     {0x1FE4, 0x1FE4, 0x03A1}, {0x1FEC, 0x1FE5, 0x03A1},
1065     {0x1FE6, 0x1FE6, 0x03A5}, {0x1FE7, 0x1FE7, 0x03A5},
1066     {0x1FE8, 0x1FE0, 0x03A5}, {0x1FE9, 0x1FE1, 0x03A5},
1067     {0x1FEA, 0x1F7A, 0x03A5}, {0x1FEB, 0x1F7B, 0x1FEB},
1068     {0x1FEC, 0x1FE5, 0x03A1}, {0x1FED, 0x1FED, 0x1FED},
1069     {0x1FEE, 0x1FEE, 0x1FEE}, {0x1FEF, 0x1FEF, 0x1FEF},
1070     {0x1FF0, 0x1FF0, 0x1FF0}, {0x1FF1, 0x1FF1, 0x1FF1},
1071     {0x1FF2, 0x1FF2, 0x03A9}, {0x1FFC, 0x1FF3, 0x03A9},
1072     {0x1FF4, 0x1FF4, 0x03A9}, {0x1FF5, 0x1FF5, 0x1FF5},
1073     {0x1FF6, 0x1FF6, 0x03A9}, {0x1FF7, 0x1FF7, 0x03A9},
1074     {0x1FF8, 0x1F78, 0x039F}, {0x1FF9, 0x1F79, 0x1FF9},
1075     {0x1FFA, 0x1F7C, 0x03A9}, {0x1FFB, 0x1F7D, 0x1FFB},
1076     {0x1FFC, 0x1FF3, 0x03A9}, {0x1FFD, 0x1FFD, 0x1FFD},
1077     {0x1FFE, 0x1FFE, 0x1FFE}, {0x1FFF, 0x1FFF, 0x1FFF}
1078 };
1079 
1080 static MY_UNICASE_INFO plane21[] = {
1081     {0x2100, 0x2100, 0x2100}, {0x2101, 0x2101, 0x2101},
1082     {0x2102, 0x2102, 0x2102}, {0x2103, 0x2103, 0x2103},
1083     {0x2104, 0x2104, 0x2104}, {0x2105, 0x2105, 0x2105},
1084     {0x2106, 0x2106, 0x2106}, {0x2107, 0x2107, 0x2107},
1085     {0x2108, 0x2108, 0x2108}, {0x2109, 0x2109, 0x2109},
1086     {0x210A, 0x210A, 0x210A}, {0x210B, 0x210B, 0x210B},
1087     {0x210C, 0x210C, 0x210C}, {0x210D, 0x210D, 0x210D},
1088     {0x210E, 0x210E, 0x210E}, {0x210F, 0x210F, 0x210F},
1089     {0x2110, 0x2110, 0x2110}, {0x2111, 0x2111, 0x2111},
1090     {0x2112, 0x2112, 0x2112}, {0x2113, 0x2113, 0x2113},
1091     {0x2114, 0x2114, 0x2114}, {0x2115, 0x2115, 0x2115},
1092     {0x2116, 0x2116, 0x2116}, {0x2117, 0x2117, 0x2117},
1093     {0x2118, 0x2118, 0x2118}, {0x2119, 0x2119, 0x2119},
1094     {0x211A, 0x211A, 0x211A}, {0x211B, 0x211B, 0x211B},
1095     {0x211C, 0x211C, 0x211C}, {0x211D, 0x211D, 0x211D},
1096     {0x211E, 0x211E, 0x211E}, {0x211F, 0x211F, 0x211F},
1097     {0x2120, 0x2120, 0x2120}, {0x2121, 0x2121, 0x2121},
1098     {0x2122, 0x2122, 0x2122}, {0x2123, 0x2123, 0x2123},
1099     {0x2124, 0x2124, 0x2124}, {0x2125, 0x2125, 0x2125},
1100     {0x2126, 0x03C9, 0x2126}, {0x2127, 0x2127, 0x2127},
1101     {0x2128, 0x2128, 0x2128}, {0x2129, 0x2129, 0x2129},
1102     {0x212A, 0x006B, 0x212A}, {0x212B, 0x00E5, 0x212B},
1103     {0x212C, 0x212C, 0x212C}, {0x212D, 0x212D, 0x212D},
1104     {0x212E, 0x212E, 0x212E}, {0x212F, 0x212F, 0x212F},
1105     {0x2130, 0x2130, 0x2130}, {0x2131, 0x2131, 0x2131},
1106     {0x2132, 0x2132, 0x2132}, {0x2133, 0x2133, 0x2133},
1107     {0x2134, 0x2134, 0x2134}, {0x2135, 0x2135, 0x2135},
1108     {0x2136, 0x2136, 0x2136}, {0x2137, 0x2137, 0x2137},
1109     {0x2138, 0x2138, 0x2138}, {0x2139, 0x2139, 0x2139},
1110     {0x213A, 0x213A, 0x213A}, {0x213B, 0x213B, 0x213B},
1111     {0x213C, 0x213C, 0x213C}, {0x213D, 0x213D, 0x213D},
1112     {0x213E, 0x213E, 0x213E}, {0x213F, 0x213F, 0x213F},
1113     {0x2140, 0x2140, 0x2140}, {0x2141, 0x2141, 0x2141},
1114     {0x2142, 0x2142, 0x2142}, {0x2143, 0x2143, 0x2143},
1115     {0x2144, 0x2144, 0x2144}, {0x2145, 0x2145, 0x2145},
1116     {0x2146, 0x2146, 0x2146}, {0x2147, 0x2147, 0x2147},
1117     {0x2148, 0x2148, 0x2148}, {0x2149, 0x2149, 0x2149},
1118     {0x214A, 0x214A, 0x214A}, {0x214B, 0x214B, 0x214B},
1119     {0x214C, 0x214C, 0x214C}, {0x214D, 0x214D, 0x214D},
1120     {0x214E, 0x214E, 0x214E}, {0x214F, 0x214F, 0x214F},
1121     {0x2150, 0x2150, 0x2150}, {0x2151, 0x2151, 0x2151},
1122     {0x2152, 0x2152, 0x2152}, {0x2153, 0x2153, 0x2153},
1123     {0x2154, 0x2154, 0x2154}, {0x2155, 0x2155, 0x2155},
1124     {0x2156, 0x2156, 0x2156}, {0x2157, 0x2157, 0x2157},
1125     {0x2158, 0x2158, 0x2158}, {0x2159, 0x2159, 0x2159},
1126     {0x215A, 0x215A, 0x215A}, {0x215B, 0x215B, 0x215B},
1127     {0x215C, 0x215C, 0x215C}, {0x215D, 0x215D, 0x215D},
1128     {0x215E, 0x215E, 0x215E}, {0x215F, 0x215F, 0x215F},
1129     {0x2160, 0x2170, 0x2160}, {0x2161, 0x2171, 0x2161},
1130     {0x2162, 0x2172, 0x2162}, {0x2163, 0x2173, 0x2163},
1131     {0x2164, 0x2174, 0x2164}, {0x2165, 0x2175, 0x2165},
1132     {0x2166, 0x2176, 0x2166}, {0x2167, 0x2177, 0x2167},
1133     {0x2168, 0x2178, 0x2168}, {0x2169, 0x2179, 0x2169},
1134     {0x216A, 0x217A, 0x216A}, {0x216B, 0x217B, 0x216B},
1135     {0x216C, 0x217C, 0x216C}, {0x216D, 0x217D, 0x216D},
1136     {0x216E, 0x217E, 0x216E}, {0x216F, 0x217F, 0x216F},
1137     {0x2160, 0x2170, 0x2160}, {0x2161, 0x2171, 0x2161},
1138     {0x2162, 0x2172, 0x2162}, {0x2163, 0x2173, 0x2163},
1139     {0x2164, 0x2174, 0x2164}, {0x2165, 0x2175, 0x2165},
1140     {0x2166, 0x2176, 0x2166}, {0x2167, 0x2177, 0x2167},
1141     {0x2168, 0x2178, 0x2168}, {0x2169, 0x2179, 0x2169},
1142     {0x216A, 0x217A, 0x216A}, {0x216B, 0x217B, 0x216B},
1143     {0x216C, 0x217C, 0x216C}, {0x216D, 0x217D, 0x216D},
1144     {0x216E, 0x217E, 0x216E}, {0x216F, 0x217F, 0x216F},
1145     {0x2180, 0x2180, 0x2180}, {0x2181, 0x2181, 0x2181},
1146     {0x2182, 0x2182, 0x2182}, {0x2183, 0x2183, 0x2183},
1147     {0x2184, 0x2184, 0x2184}, {0x2185, 0x2185, 0x2185},
1148     {0x2186, 0x2186, 0x2186}, {0x2187, 0x2187, 0x2187},
1149     {0x2188, 0x2188, 0x2188}, {0x2189, 0x2189, 0x2189},
1150     {0x218A, 0x218A, 0x218A}, {0x218B, 0x218B, 0x218B},
1151     {0x218C, 0x218C, 0x218C}, {0x218D, 0x218D, 0x218D},
1152     {0x218E, 0x218E, 0x218E}, {0x218F, 0x218F, 0x218F},
1153     {0x2190, 0x2190, 0x2190}, {0x2191, 0x2191, 0x2191},
1154     {0x2192, 0x2192, 0x2192}, {0x2193, 0x2193, 0x2193},
1155     {0x2194, 0x2194, 0x2194}, {0x2195, 0x2195, 0x2195},
1156     {0x2196, 0x2196, 0x2196}, {0x2197, 0x2197, 0x2197},
1157     {0x2198, 0x2198, 0x2198}, {0x2199, 0x2199, 0x2199},
1158     {0x219A, 0x219A, 0x219A}, {0x219B, 0x219B, 0x219B},
1159     {0x219C, 0x219C, 0x219C}, {0x219D, 0x219D, 0x219D},
1160     {0x219E, 0x219E, 0x219E}, {0x219F, 0x219F, 0x219F},
1161     {0x21A0, 0x21A0, 0x21A0}, {0x21A1, 0x21A1, 0x21A1},
1162     {0x21A2, 0x21A2, 0x21A2}, {0x21A3, 0x21A3, 0x21A3},
1163     {0x21A4, 0x21A4, 0x21A4}, {0x21A5, 0x21A5, 0x21A5},
1164     {0x21A6, 0x21A6, 0x21A6}, {0x21A7, 0x21A7, 0x21A7},
1165     {0x21A8, 0x21A8, 0x21A8}, {0x21A9, 0x21A9, 0x21A9},
1166     {0x21AA, 0x21AA, 0x21AA}, {0x21AB, 0x21AB, 0x21AB},
1167     {0x21AC, 0x21AC, 0x21AC}, {0x21AD, 0x21AD, 0x21AD},
1168     {0x21AE, 0x21AE, 0x21AE}, {0x21AF, 0x21AF, 0x21AF},
1169     {0x21B0, 0x21B0, 0x21B0}, {0x21B1, 0x21B1, 0x21B1},
1170     {0x21B2, 0x21B2, 0x21B2}, {0x21B3, 0x21B3, 0x21B3},
1171     {0x21B4, 0x21B4, 0x21B4}, {0x21B5, 0x21B5, 0x21B5},
1172     {0x21B6, 0x21B6, 0x21B6}, {0x21B7, 0x21B7, 0x21B7},
1173     {0x21B8, 0x21B8, 0x21B8}, {0x21B9, 0x21B9, 0x21B9},
1174     {0x21BA, 0x21BA, 0x21BA}, {0x21BB, 0x21BB, 0x21BB},
1175     {0x21BC, 0x21BC, 0x21BC}, {0x21BD, 0x21BD, 0x21BD},
1176     {0x21BE, 0x21BE, 0x21BE}, {0x21BF, 0x21BF, 0x21BF},
1177     {0x21C0, 0x21C0, 0x21C0}, {0x21C1, 0x21C1, 0x21C1},
1178     {0x21C2, 0x21C2, 0x21C2}, {0x21C3, 0x21C3, 0x21C3},
1179     {0x21C4, 0x21C4, 0x21C4}, {0x21C5, 0x21C5, 0x21C5},
1180     {0x21C6, 0x21C6, 0x21C6}, {0x21C7, 0x21C7, 0x21C7},
1181     {0x21C8, 0x21C8, 0x21C8}, {0x21C9, 0x21C9, 0x21C9},
1182     {0x21CA, 0x21CA, 0x21CA}, {0x21CB, 0x21CB, 0x21CB},
1183     {0x21CC, 0x21CC, 0x21CC}, {0x21CD, 0x21CD, 0x21CD},
1184     {0x21CE, 0x21CE, 0x21CE}, {0x21CF, 0x21CF, 0x21CF},
1185     {0x21D0, 0x21D0, 0x21D0}, {0x21D1, 0x21D1, 0x21D1},
1186     {0x21D2, 0x21D2, 0x21D2}, {0x21D3, 0x21D3, 0x21D3},
1187     {0x21D4, 0x21D4, 0x21D4}, {0x21D5, 0x21D5, 0x21D5},
1188     {0x21D6, 0x21D6, 0x21D6}, {0x21D7, 0x21D7, 0x21D7},
1189     {0x21D8, 0x21D8, 0x21D8}, {0x21D9, 0x21D9, 0x21D9},
1190     {0x21DA, 0x21DA, 0x21DA}, {0x21DB, 0x21DB, 0x21DB},
1191     {0x21DC, 0x21DC, 0x21DC}, {0x21DD, 0x21DD, 0x21DD},
1192     {0x21DE, 0x21DE, 0x21DE}, {0x21DF, 0x21DF, 0x21DF},
1193     {0x21E0, 0x21E0, 0x21E0}, {0x21E1, 0x21E1, 0x21E1},
1194     {0x21E2, 0x21E2, 0x21E2}, {0x21E3, 0x21E3, 0x21E3},
1195     {0x21E4, 0x21E4, 0x21E4}, {0x21E5, 0x21E5, 0x21E5},
1196     {0x21E6, 0x21E6, 0x21E6}, {0x21E7, 0x21E7, 0x21E7},
1197     {0x21E8, 0x21E8, 0x21E8}, {0x21E9, 0x21E9, 0x21E9},
1198     {0x21EA, 0x21EA, 0x21EA}, {0x21EB, 0x21EB, 0x21EB},
1199     {0x21EC, 0x21EC, 0x21EC}, {0x21ED, 0x21ED, 0x21ED},
1200     {0x21EE, 0x21EE, 0x21EE}, {0x21EF, 0x21EF, 0x21EF},
1201     {0x21F0, 0x21F0, 0x21F0}, {0x21F1, 0x21F1, 0x21F1},
1202     {0x21F2, 0x21F2, 0x21F2}, {0x21F3, 0x21F3, 0x21F3},
1203     {0x21F4, 0x21F4, 0x21F4}, {0x21F5, 0x21F5, 0x21F5},
1204     {0x21F6, 0x21F6, 0x21F6}, {0x21F7, 0x21F7, 0x21F7},
1205     {0x21F8, 0x21F8, 0x21F8}, {0x21F9, 0x21F9, 0x21F9},
1206     {0x21FA, 0x21FA, 0x21FA}, {0x21FB, 0x21FB, 0x21FB},
1207     {0x21FC, 0x21FC, 0x21FC}, {0x21FD, 0x21FD, 0x21FD},
1208     {0x21FE, 0x21FE, 0x21FE}, {0x21FF, 0x21FF, 0x21FF}
1209 };
1210 
1211 static MY_UNICASE_INFO plane24[] = {
1212     {0x2400, 0x2400, 0x2400}, {0x2401, 0x2401, 0x2401},
1213     {0x2402, 0x2402, 0x2402}, {0x2403, 0x2403, 0x2403},
1214     {0x2404, 0x2404, 0x2404}, {0x2405, 0x2405, 0x2405},
1215     {0x2406, 0x2406, 0x2406}, {0x2407, 0x2407, 0x2407},
1216     {0x2408, 0x2408, 0x2408}, {0x2409, 0x2409, 0x2409},
1217     {0x240A, 0x240A, 0x240A}, {0x240B, 0x240B, 0x240B},
1218     {0x240C, 0x240C, 0x240C}, {0x240D, 0x240D, 0x240D},
1219     {0x240E, 0x240E, 0x240E}, {0x240F, 0x240F, 0x240F},
1220     {0x2410, 0x2410, 0x2410}, {0x2411, 0x2411, 0x2411},
1221     {0x2412, 0x2412, 0x2412}, {0x2413, 0x2413, 0x2413},
1222     {0x2414, 0x2414, 0x2414}, {0x2415, 0x2415, 0x2415},
1223     {0x2416, 0x2416, 0x2416}, {0x2417, 0x2417, 0x2417},
1224     {0x2418, 0x2418, 0x2418}, {0x2419, 0x2419, 0x2419},
1225     {0x241A, 0x241A, 0x241A}, {0x241B, 0x241B, 0x241B},
1226     {0x241C, 0x241C, 0x241C}, {0x241D, 0x241D, 0x241D},
1227     {0x241E, 0x241E, 0x241E}, {0x241F, 0x241F, 0x241F},
1228     {0x2420, 0x2420, 0x2420}, {0x2421, 0x2421, 0x2421},
1229     {0x2422, 0x2422, 0x2422}, {0x2423, 0x2423, 0x2423},
1230     {0x2424, 0x2424, 0x2424}, {0x2425, 0x2425, 0x2425},
1231     {0x2426, 0x2426, 0x2426}, {0x2427, 0x2427, 0x2427},
1232     {0x2428, 0x2428, 0x2428}, {0x2429, 0x2429, 0x2429},
1233     {0x242A, 0x242A, 0x242A}, {0x242B, 0x242B, 0x242B},
1234     {0x242C, 0x242C, 0x242C}, {0x242D, 0x242D, 0x242D},
1235     {0x242E, 0x242E, 0x242E}, {0x242F, 0x242F, 0x242F},
1236     {0x2430, 0x2430, 0x2430}, {0x2431, 0x2431, 0x2431},
1237     {0x2432, 0x2432, 0x2432}, {0x2433, 0x2433, 0x2433},
1238     {0x2434, 0x2434, 0x2434}, {0x2435, 0x2435, 0x2435},
1239     {0x2436, 0x2436, 0x2436}, {0x2437, 0x2437, 0x2437},
1240     {0x2438, 0x2438, 0x2438}, {0x2439, 0x2439, 0x2439},
1241     {0x243A, 0x243A, 0x243A}, {0x243B, 0x243B, 0x243B},
1242     {0x243C, 0x243C, 0x243C}, {0x243D, 0x243D, 0x243D},
1243     {0x243E, 0x243E, 0x243E}, {0x243F, 0x243F, 0x243F},
1244     {0x2440, 0x2440, 0x2440}, {0x2441, 0x2441, 0x2441},
1245     {0x2442, 0x2442, 0x2442}, {0x2443, 0x2443, 0x2443},
1246     {0x2444, 0x2444, 0x2444}, {0x2445, 0x2445, 0x2445},
1247     {0x2446, 0x2446, 0x2446}, {0x2447, 0x2447, 0x2447},
1248     {0x2448, 0x2448, 0x2448}, {0x2449, 0x2449, 0x2449},
1249     {0x244A, 0x244A, 0x244A}, {0x244B, 0x244B, 0x244B},
1250     {0x244C, 0x244C, 0x244C}, {0x244D, 0x244D, 0x244D},
1251     {0x244E, 0x244E, 0x244E}, {0x244F, 0x244F, 0x244F},
1252     {0x2450, 0x2450, 0x2450}, {0x2451, 0x2451, 0x2451},
1253     {0x2452, 0x2452, 0x2452}, {0x2453, 0x2453, 0x2453},
1254     {0x2454, 0x2454, 0x2454}, {0x2455, 0x2455, 0x2455},
1255     {0x2456, 0x2456, 0x2456}, {0x2457, 0x2457, 0x2457},
1256     {0x2458, 0x2458, 0x2458}, {0x2459, 0x2459, 0x2459},
1257     {0x245A, 0x245A, 0x245A}, {0x245B, 0x245B, 0x245B},
1258     {0x245C, 0x245C, 0x245C}, {0x245D, 0x245D, 0x245D},
1259     {0x245E, 0x245E, 0x245E}, {0x245F, 0x245F, 0x245F},
1260     {0x2460, 0x2460, 0x2460}, {0x2461, 0x2461, 0x2461},
1261     {0x2462, 0x2462, 0x2462}, {0x2463, 0x2463, 0x2463},
1262     {0x2464, 0x2464, 0x2464}, {0x2465, 0x2465, 0x2465},
1263     {0x2466, 0x2466, 0x2466}, {0x2467, 0x2467, 0x2467},
1264     {0x2468, 0x2468, 0x2468}, {0x2469, 0x2469, 0x2469},
1265     {0x246A, 0x246A, 0x246A}, {0x246B, 0x246B, 0x246B},
1266     {0x246C, 0x246C, 0x246C}, {0x246D, 0x246D, 0x246D},
1267     {0x246E, 0x246E, 0x246E}, {0x246F, 0x246F, 0x246F},
1268     {0x2470, 0x2470, 0x2470}, {0x2471, 0x2471, 0x2471},
1269     {0x2472, 0x2472, 0x2472}, {0x2473, 0x2473, 0x2473},
1270     {0x2474, 0x2474, 0x2474}, {0x2475, 0x2475, 0x2475},
1271     {0x2476, 0x2476, 0x2476}, {0x2477, 0x2477, 0x2477},
1272     {0x2478, 0x2478, 0x2478}, {0x2479, 0x2479, 0x2479},
1273     {0x247A, 0x247A, 0x247A}, {0x247B, 0x247B, 0x247B},
1274     {0x247C, 0x247C, 0x247C}, {0x247D, 0x247D, 0x247D},
1275     {0x247E, 0x247E, 0x247E}, {0x247F, 0x247F, 0x247F},
1276     {0x2480, 0x2480, 0x2480}, {0x2481, 0x2481, 0x2481},
1277     {0x2482, 0x2482, 0x2482}, {0x2483, 0x2483, 0x2483},
1278     {0x2484, 0x2484, 0x2484}, {0x2485, 0x2485, 0x2485},
1279     {0x2486, 0x2486, 0x2486}, {0x2487, 0x2487, 0x2487},
1280     {0x2488, 0x2488, 0x2488}, {0x2489, 0x2489, 0x2489},
1281     {0x248A, 0x248A, 0x248A}, {0x248B, 0x248B, 0x248B},
1282     {0x248C, 0x248C, 0x248C}, {0x248D, 0x248D, 0x248D},
1283     {0x248E, 0x248E, 0x248E}, {0x248F, 0x248F, 0x248F},
1284     {0x2490, 0x2490, 0x2490}, {0x2491, 0x2491, 0x2491},
1285     {0x2492, 0x2492, 0x2492}, {0x2493, 0x2493, 0x2493},
1286     {0x2494, 0x2494, 0x2494}, {0x2495, 0x2495, 0x2495},
1287     {0x2496, 0x2496, 0x2496}, {0x2497, 0x2497, 0x2497},
1288     {0x2498, 0x2498, 0x2498}, {0x2499, 0x2499, 0x2499},
1289     {0x249A, 0x249A, 0x249A}, {0x249B, 0x249B, 0x249B},
1290     {0x249C, 0x249C, 0x249C}, {0x249D, 0x249D, 0x249D},
1291     {0x249E, 0x249E, 0x249E}, {0x249F, 0x249F, 0x249F},
1292     {0x24A0, 0x24A0, 0x24A0}, {0x24A1, 0x24A1, 0x24A1},
1293     {0x24A2, 0x24A2, 0x24A2}, {0x24A3, 0x24A3, 0x24A3},
1294     {0x24A4, 0x24A4, 0x24A4}, {0x24A5, 0x24A5, 0x24A5},
1295     {0x24A6, 0x24A6, 0x24A6}, {0x24A7, 0x24A7, 0x24A7},
1296     {0x24A8, 0x24A8, 0x24A8}, {0x24A9, 0x24A9, 0x24A9},
1297     {0x24AA, 0x24AA, 0x24AA}, {0x24AB, 0x24AB, 0x24AB},
1298     {0x24AC, 0x24AC, 0x24AC}, {0x24AD, 0x24AD, 0x24AD},
1299     {0x24AE, 0x24AE, 0x24AE}, {0x24AF, 0x24AF, 0x24AF},
1300     {0x24B0, 0x24B0, 0x24B0}, {0x24B1, 0x24B1, 0x24B1},
1301     {0x24B2, 0x24B2, 0x24B2}, {0x24B3, 0x24B3, 0x24B3},
1302     {0x24B4, 0x24B4, 0x24B4}, {0x24B5, 0x24B5, 0x24B5},
1303     {0x24B6, 0x24D0, 0x24B6}, {0x24B7, 0x24D1, 0x24B7},
1304     {0x24B8, 0x24D2, 0x24B8}, {0x24B9, 0x24D3, 0x24B9},
1305     {0x24BA, 0x24D4, 0x24BA}, {0x24BB, 0x24D5, 0x24BB},
1306     {0x24BC, 0x24D6, 0x24BC}, {0x24BD, 0x24D7, 0x24BD},
1307     {0x24BE, 0x24D8, 0x24BE}, {0x24BF, 0x24D9, 0x24BF},
1308     {0x24C0, 0x24DA, 0x24C0}, {0x24C1, 0x24DB, 0x24C1},
1309     {0x24C2, 0x24DC, 0x24C2}, {0x24C3, 0x24DD, 0x24C3},
1310     {0x24C4, 0x24DE, 0x24C4}, {0x24C5, 0x24DF, 0x24C5},
1311     {0x24C6, 0x24E0, 0x24C6}, {0x24C7, 0x24E1, 0x24C7},
1312     {0x24C8, 0x24E2, 0x24C8}, {0x24C9, 0x24E3, 0x24C9},
1313     {0x24CA, 0x24E4, 0x24CA}, {0x24CB, 0x24E5, 0x24CB},
1314     {0x24CC, 0x24E6, 0x24CC}, {0x24CD, 0x24E7, 0x24CD},
1315     {0x24CE, 0x24E8, 0x24CE}, {0x24CF, 0x24E9, 0x24CF},
1316     {0x24B6, 0x24D0, 0x24B6}, {0x24B7, 0x24D1, 0x24B7},
1317     {0x24B8, 0x24D2, 0x24B8}, {0x24B9, 0x24D3, 0x24B9},
1318     {0x24BA, 0x24D4, 0x24BA}, {0x24BB, 0x24D5, 0x24BB},
1319     {0x24BC, 0x24D6, 0x24BC}, {0x24BD, 0x24D7, 0x24BD},
1320     {0x24BE, 0x24D8, 0x24BE}, {0x24BF, 0x24D9, 0x24BF},
1321     {0x24C0, 0x24DA, 0x24C0}, {0x24C1, 0x24DB, 0x24C1},
1322     {0x24C2, 0x24DC, 0x24C2}, {0x24C3, 0x24DD, 0x24C3},
1323     {0x24C4, 0x24DE, 0x24C4}, {0x24C5, 0x24DF, 0x24C5},
1324     {0x24C6, 0x24E0, 0x24C6}, {0x24C7, 0x24E1, 0x24C7},
1325     {0x24C8, 0x24E2, 0x24C8}, {0x24C9, 0x24E3, 0x24C9},
1326     {0x24CA, 0x24E4, 0x24CA}, {0x24CB, 0x24E5, 0x24CB},
1327     {0x24CC, 0x24E6, 0x24CC}, {0x24CD, 0x24E7, 0x24CD},
1328     {0x24CE, 0x24E8, 0x24CE}, {0x24CF, 0x24E9, 0x24CF},
1329     {0x24EA, 0x24EA, 0x24EA}, {0x24EB, 0x24EB, 0x24EB},
1330     {0x24EC, 0x24EC, 0x24EC}, {0x24ED, 0x24ED, 0x24ED},
1331     {0x24EE, 0x24EE, 0x24EE}, {0x24EF, 0x24EF, 0x24EF},
1332     {0x24F0, 0x24F0, 0x24F0}, {0x24F1, 0x24F1, 0x24F1},
1333     {0x24F2, 0x24F2, 0x24F2}, {0x24F3, 0x24F3, 0x24F3},
1334     {0x24F4, 0x24F4, 0x24F4}, {0x24F5, 0x24F5, 0x24F5},
1335     {0x24F6, 0x24F6, 0x24F6}, {0x24F7, 0x24F7, 0x24F7},
1336     {0x24F8, 0x24F8, 0x24F8}, {0x24F9, 0x24F9, 0x24F9},
1337     {0x24FA, 0x24FA, 0x24FA}, {0x24FB, 0x24FB, 0x24FB},
1338     {0x24FC, 0x24FC, 0x24FC}, {0x24FD, 0x24FD, 0x24FD},
1339     {0x24FE, 0x24FE, 0x24FE}, {0x24FF, 0x24FF, 0x24FF}
1340 };
1341 
1342 static MY_UNICASE_INFO planeFF[] = {
1343     {0xFF00, 0xFF00, 0xFF00}, {0xFF01, 0xFF01, 0xFF01},
1344     {0xFF02, 0xFF02, 0xFF02}, {0xFF03, 0xFF03, 0xFF03},
1345     {0xFF04, 0xFF04, 0xFF04}, {0xFF05, 0xFF05, 0xFF05},
1346     {0xFF06, 0xFF06, 0xFF06}, {0xFF07, 0xFF07, 0xFF07},
1347     {0xFF08, 0xFF08, 0xFF08}, {0xFF09, 0xFF09, 0xFF09},
1348     {0xFF0A, 0xFF0A, 0xFF0A}, {0xFF0B, 0xFF0B, 0xFF0B},
1349     {0xFF0C, 0xFF0C, 0xFF0C}, {0xFF0D, 0xFF0D, 0xFF0D},
1350     {0xFF0E, 0xFF0E, 0xFF0E}, {0xFF0F, 0xFF0F, 0xFF0F},
1351     {0xFF10, 0xFF10, 0xFF10}, {0xFF11, 0xFF11, 0xFF11},
1352     {0xFF12, 0xFF12, 0xFF12}, {0xFF13, 0xFF13, 0xFF13},
1353     {0xFF14, 0xFF14, 0xFF14}, {0xFF15, 0xFF15, 0xFF15},
1354     {0xFF16, 0xFF16, 0xFF16}, {0xFF17, 0xFF17, 0xFF17},
1355     {0xFF18, 0xFF18, 0xFF18}, {0xFF19, 0xFF19, 0xFF19},
1356     {0xFF1A, 0xFF1A, 0xFF1A}, {0xFF1B, 0xFF1B, 0xFF1B},
1357     {0xFF1C, 0xFF1C, 0xFF1C}, {0xFF1D, 0xFF1D, 0xFF1D},
1358     {0xFF1E, 0xFF1E, 0xFF1E}, {0xFF1F, 0xFF1F, 0xFF1F},
1359     {0xFF20, 0xFF20, 0xFF20}, {0xFF21, 0xFF41, 0xFF21},
1360     {0xFF22, 0xFF42, 0xFF22}, {0xFF23, 0xFF43, 0xFF23},
1361     {0xFF24, 0xFF44, 0xFF24}, {0xFF25, 0xFF45, 0xFF25},
1362     {0xFF26, 0xFF46, 0xFF26}, {0xFF27, 0xFF47, 0xFF27},
1363     {0xFF28, 0xFF48, 0xFF28}, {0xFF29, 0xFF49, 0xFF29},
1364     {0xFF2A, 0xFF4A, 0xFF2A}, {0xFF2B, 0xFF4B, 0xFF2B},
1365     {0xFF2C, 0xFF4C, 0xFF2C}, {0xFF2D, 0xFF4D, 0xFF2D},
1366     {0xFF2E, 0xFF4E, 0xFF2E}, {0xFF2F, 0xFF4F, 0xFF2F},
1367     {0xFF30, 0xFF50, 0xFF30}, {0xFF31, 0xFF51, 0xFF31},
1368     {0xFF32, 0xFF52, 0xFF32}, {0xFF33, 0xFF53, 0xFF33},
1369     {0xFF34, 0xFF54, 0xFF34}, {0xFF35, 0xFF55, 0xFF35},
1370     {0xFF36, 0xFF56, 0xFF36}, {0xFF37, 0xFF57, 0xFF37},
1371     {0xFF38, 0xFF58, 0xFF38}, {0xFF39, 0xFF59, 0xFF39},
1372     {0xFF3A, 0xFF5A, 0xFF3A}, {0xFF3B, 0xFF3B, 0xFF3B},
1373     {0xFF3C, 0xFF3C, 0xFF3C}, {0xFF3D, 0xFF3D, 0xFF3D},
1374     {0xFF3E, 0xFF3E, 0xFF3E}, {0xFF3F, 0xFF3F, 0xFF3F},
1375     {0xFF40, 0xFF40, 0xFF40}, {0xFF21, 0xFF41, 0xFF21},
1376     {0xFF22, 0xFF42, 0xFF22}, {0xFF23, 0xFF43, 0xFF23},
1377     {0xFF24, 0xFF44, 0xFF24}, {0xFF25, 0xFF45, 0xFF25},
1378     {0xFF26, 0xFF46, 0xFF26}, {0xFF27, 0xFF47, 0xFF27},
1379     {0xFF28, 0xFF48, 0xFF28}, {0xFF29, 0xFF49, 0xFF29},
1380     {0xFF2A, 0xFF4A, 0xFF2A}, {0xFF2B, 0xFF4B, 0xFF2B},
1381     {0xFF2C, 0xFF4C, 0xFF2C}, {0xFF2D, 0xFF4D, 0xFF2D},
1382     {0xFF2E, 0xFF4E, 0xFF2E}, {0xFF2F, 0xFF4F, 0xFF2F},
1383     {0xFF30, 0xFF50, 0xFF30}, {0xFF31, 0xFF51, 0xFF31},
1384     {0xFF32, 0xFF52, 0xFF32}, {0xFF33, 0xFF53, 0xFF33},
1385     {0xFF34, 0xFF54, 0xFF34}, {0xFF35, 0xFF55, 0xFF35},
1386     {0xFF36, 0xFF56, 0xFF36}, {0xFF37, 0xFF57, 0xFF37},
1387     {0xFF38, 0xFF58, 0xFF38}, {0xFF39, 0xFF59, 0xFF39},
1388     {0xFF3A, 0xFF5A, 0xFF3A}, {0xFF5B, 0xFF5B, 0xFF5B},
1389     {0xFF5C, 0xFF5C, 0xFF5C}, {0xFF5D, 0xFF5D, 0xFF5D},
1390     {0xFF5E, 0xFF5E, 0xFF5E}, {0xFF5F, 0xFF5F, 0xFF5F},
1391     {0xFF60, 0xFF60, 0xFF60}, {0xFF61, 0xFF61, 0xFF61},
1392     {0xFF62, 0xFF62, 0xFF62}, {0xFF63, 0xFF63, 0xFF63},
1393     {0xFF64, 0xFF64, 0xFF64}, {0xFF65, 0xFF65, 0xFF65},
1394     {0xFF66, 0xFF66, 0xFF66}, {0xFF67, 0xFF67, 0xFF67},
1395     {0xFF68, 0xFF68, 0xFF68}, {0xFF69, 0xFF69, 0xFF69},
1396     {0xFF6A, 0xFF6A, 0xFF6A}, {0xFF6B, 0xFF6B, 0xFF6B},
1397     {0xFF6C, 0xFF6C, 0xFF6C}, {0xFF6D, 0xFF6D, 0xFF6D},
1398     {0xFF6E, 0xFF6E, 0xFF6E}, {0xFF6F, 0xFF6F, 0xFF6F},
1399     {0xFF70, 0xFF70, 0xFF70}, {0xFF71, 0xFF71, 0xFF71},
1400     {0xFF72, 0xFF72, 0xFF72}, {0xFF73, 0xFF73, 0xFF73},
1401     {0xFF74, 0xFF74, 0xFF74}, {0xFF75, 0xFF75, 0xFF75},
1402     {0xFF76, 0xFF76, 0xFF76}, {0xFF77, 0xFF77, 0xFF77},
1403     {0xFF78, 0xFF78, 0xFF78}, {0xFF79, 0xFF79, 0xFF79},
1404     {0xFF7A, 0xFF7A, 0xFF7A}, {0xFF7B, 0xFF7B, 0xFF7B},
1405     {0xFF7C, 0xFF7C, 0xFF7C}, {0xFF7D, 0xFF7D, 0xFF7D},
1406     {0xFF7E, 0xFF7E, 0xFF7E}, {0xFF7F, 0xFF7F, 0xFF7F},
1407     {0xFF80, 0xFF80, 0xFF80}, {0xFF81, 0xFF81, 0xFF81},
1408     {0xFF82, 0xFF82, 0xFF82}, {0xFF83, 0xFF83, 0xFF83},
1409     {0xFF84, 0xFF84, 0xFF84}, {0xFF85, 0xFF85, 0xFF85},
1410     {0xFF86, 0xFF86, 0xFF86}, {0xFF87, 0xFF87, 0xFF87},
1411     {0xFF88, 0xFF88, 0xFF88}, {0xFF89, 0xFF89, 0xFF89},
1412     {0xFF8A, 0xFF8A, 0xFF8A}, {0xFF8B, 0xFF8B, 0xFF8B},
1413     {0xFF8C, 0xFF8C, 0xFF8C}, {0xFF8D, 0xFF8D, 0xFF8D},
1414     {0xFF8E, 0xFF8E, 0xFF8E}, {0xFF8F, 0xFF8F, 0xFF8F},
1415     {0xFF90, 0xFF90, 0xFF90}, {0xFF91, 0xFF91, 0xFF91},
1416     {0xFF92, 0xFF92, 0xFF92}, {0xFF93, 0xFF93, 0xFF93},
1417     {0xFF94, 0xFF94, 0xFF94}, {0xFF95, 0xFF95, 0xFF95},
1418     {0xFF96, 0xFF96, 0xFF96}, {0xFF97, 0xFF97, 0xFF97},
1419     {0xFF98, 0xFF98, 0xFF98}, {0xFF99, 0xFF99, 0xFF99},
1420     {0xFF9A, 0xFF9A, 0xFF9A}, {0xFF9B, 0xFF9B, 0xFF9B},
1421     {0xFF9C, 0xFF9C, 0xFF9C}, {0xFF9D, 0xFF9D, 0xFF9D},
1422     {0xFF9E, 0xFF9E, 0xFF9E}, {0xFF9F, 0xFF9F, 0xFF9F},
1423     {0xFFA0, 0xFFA0, 0xFFA0}, {0xFFA1, 0xFFA1, 0xFFA1},
1424     {0xFFA2, 0xFFA2, 0xFFA2}, {0xFFA3, 0xFFA3, 0xFFA3},
1425     {0xFFA4, 0xFFA4, 0xFFA4}, {0xFFA5, 0xFFA5, 0xFFA5},
1426     {0xFFA6, 0xFFA6, 0xFFA6}, {0xFFA7, 0xFFA7, 0xFFA7},
1427     {0xFFA8, 0xFFA8, 0xFFA8}, {0xFFA9, 0xFFA9, 0xFFA9},
1428     {0xFFAA, 0xFFAA, 0xFFAA}, {0xFFAB, 0xFFAB, 0xFFAB},
1429     {0xFFAC, 0xFFAC, 0xFFAC}, {0xFFAD, 0xFFAD, 0xFFAD},
1430     {0xFFAE, 0xFFAE, 0xFFAE}, {0xFFAF, 0xFFAF, 0xFFAF},
1431     {0xFFB0, 0xFFB0, 0xFFB0}, {0xFFB1, 0xFFB1, 0xFFB1},
1432     {0xFFB2, 0xFFB2, 0xFFB2}, {0xFFB3, 0xFFB3, 0xFFB3},
1433     {0xFFB4, 0xFFB4, 0xFFB4}, {0xFFB5, 0xFFB5, 0xFFB5},
1434     {0xFFB6, 0xFFB6, 0xFFB6}, {0xFFB7, 0xFFB7, 0xFFB7},
1435     {0xFFB8, 0xFFB8, 0xFFB8}, {0xFFB9, 0xFFB9, 0xFFB9},
1436     {0xFFBA, 0xFFBA, 0xFFBA}, {0xFFBB, 0xFFBB, 0xFFBB},
1437     {0xFFBC, 0xFFBC, 0xFFBC}, {0xFFBD, 0xFFBD, 0xFFBD},
1438     {0xFFBE, 0xFFBE, 0xFFBE}, {0xFFBF, 0xFFBF, 0xFFBF},
1439     {0xFFC0, 0xFFC0, 0xFFC0}, {0xFFC1, 0xFFC1, 0xFFC1},
1440     {0xFFC2, 0xFFC2, 0xFFC2}, {0xFFC3, 0xFFC3, 0xFFC3},
1441     {0xFFC4, 0xFFC4, 0xFFC4}, {0xFFC5, 0xFFC5, 0xFFC5},
1442     {0xFFC6, 0xFFC6, 0xFFC6}, {0xFFC7, 0xFFC7, 0xFFC7},
1443     {0xFFC8, 0xFFC8, 0xFFC8}, {0xFFC9, 0xFFC9, 0xFFC9},
1444     {0xFFCA, 0xFFCA, 0xFFCA}, {0xFFCB, 0xFFCB, 0xFFCB},
1445     {0xFFCC, 0xFFCC, 0xFFCC}, {0xFFCD, 0xFFCD, 0xFFCD},
1446     {0xFFCE, 0xFFCE, 0xFFCE}, {0xFFCF, 0xFFCF, 0xFFCF},
1447     {0xFFD0, 0xFFD0, 0xFFD0}, {0xFFD1, 0xFFD1, 0xFFD1},
1448     {0xFFD2, 0xFFD2, 0xFFD2}, {0xFFD3, 0xFFD3, 0xFFD3},
1449     {0xFFD4, 0xFFD4, 0xFFD4}, {0xFFD5, 0xFFD5, 0xFFD5},
1450     {0xFFD6, 0xFFD6, 0xFFD6}, {0xFFD7, 0xFFD7, 0xFFD7},
1451     {0xFFD8, 0xFFD8, 0xFFD8}, {0xFFD9, 0xFFD9, 0xFFD9},
1452     {0xFFDA, 0xFFDA, 0xFFDA}, {0xFFDB, 0xFFDB, 0xFFDB},
1453     {0xFFDC, 0xFFDC, 0xFFDC}, {0xFFDD, 0xFFDD, 0xFFDD},
1454     {0xFFDE, 0xFFDE, 0xFFDE}, {0xFFDF, 0xFFDF, 0xFFDF},
1455     {0xFFE0, 0xFFE0, 0xFFE0}, {0xFFE1, 0xFFE1, 0xFFE1},
1456     {0xFFE2, 0xFFE2, 0xFFE2}, {0xFFE3, 0xFFE3, 0xFFE3},
1457     {0xFFE4, 0xFFE4, 0xFFE4}, {0xFFE5, 0xFFE5, 0xFFE5},
1458     {0xFFE6, 0xFFE6, 0xFFE6}, {0xFFE7, 0xFFE7, 0xFFE7},
1459     {0xFFE8, 0xFFE8, 0xFFE8}, {0xFFE9, 0xFFE9, 0xFFE9},
1460     {0xFFEA, 0xFFEA, 0xFFEA}, {0xFFEB, 0xFFEB, 0xFFEB},
1461     {0xFFEC, 0xFFEC, 0xFFEC}, {0xFFED, 0xFFED, 0xFFED},
1462     {0xFFEE, 0xFFEE, 0xFFEE}, {0xFFEF, 0xFFEF, 0xFFEF},
1463     {0xFFF0, 0xFFF0, 0xFFF0}, {0xFFF1, 0xFFF1, 0xFFF1},
1464     {0xFFF2, 0xFFF2, 0xFFF2}, {0xFFF3, 0xFFF3, 0xFFF3},
1465     {0xFFF4, 0xFFF4, 0xFFF4}, {0xFFF5, 0xFFF5, 0xFFF5},
1466     {0xFFF6, 0xFFF6, 0xFFF6}, {0xFFF7, 0xFFF7, 0xFFF7},
1467     {0xFFF8, 0xFFF8, 0xFFF8}, {0xFFF9, 0xFFF9, 0xFFF9},
1468     {0xFFFA, 0xFFFA, 0xFFFA}, {0xFFFB, 0xFFFB, 0xFFFB},
1469     {0xFFFC, 0xFFFC, 0xFFFC}, {0xFFFD, 0xFFFD, 0xFFFD},
1470     {0xFFFE, 0xFFFE, 0xFFFE}, {0xFFFF, 0xFFFF, 0xFFFF}
1471 };
1472 
1473 MY_UNICASE_INFO *uni_plane[256] = {
1474     plane00, plane01, plane02, plane03, plane04, plane05, NULL, NULL,
1475     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1476     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1477     NULL, NULL, NULL, NULL, NULL, NULL, plane1E, plane1F,
1478     NULL, plane21, NULL, NULL, plane24, NULL, NULL, NULL,
1479     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1480     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1481     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1482     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1483     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1484     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1485     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1486     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1487     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1488     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1489     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1490     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1491     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1492     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1493     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1494     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1495     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1496     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1497     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1498     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1499     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1500     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1501     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1502     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1503     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1504     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1505     NULL, NULL, NULL, NULL, NULL, NULL, NULL, planeFF
1506 };
1507 
1508 
1509 size_t
utf8_char_width(const char * ch)1510 utf8_char_width(const char *ch)
1511 {
1512     const unsigned char *p = (const unsigned char *)ch;
1513     if (*p <= 0x7f)
1514 	return 1;
1515     if (0xc2 <= *p && *p <= 0xdf)
1516 	return 2;
1517     if (0xe0 <= *p && *p <= 0xef)
1518 	return 3;
1519     if (0xf0 <= *p && *p <= 0xf4)
1520 	return 4;
1521     return 0;
1522 }
1523 
1524 size_t
utf8_strlen(const char * s)1525 utf8_strlen(const char *s)
1526 {
1527     size_t len = 0;
1528     size_t n;
1529 
1530     while (*s && (n = utf8_char_width(s)) != 0) {
1531 	len++;
1532 	s += n;
1533     }
1534     return len;
1535 }
1536 
1537 
1538 static int
utf8_iter0(struct utf8_iterator * itr)1539 utf8_iter0(struct utf8_iterator *itr)
1540 {
1541     size_t n;
1542 
1543     if (itr->length == 0) {
1544 	itr->end = 1;
1545 	return 1;
1546     }
1547     n = utf8_char_width(itr->curptr);
1548     if (n == 0 || n > itr->length) {
1549 	itr->end = 1;
1550 	itr->err = 1;
1551 	return 1;
1552     }
1553 
1554     itr->curwidth = n;
1555     return 0;
1556 }
1557 
1558 int
utf8_iter_end_p(struct utf8_iterator * itr)1559 utf8_iter_end_p(struct utf8_iterator *itr)
1560 {
1561     return itr->end;
1562 }
1563 
1564 int
utf8_iter_err_p(struct utf8_iterator * itr)1565 utf8_iter_err_p(struct utf8_iterator *itr)
1566 {
1567     return itr->end;
1568 }
1569 
1570 int
utf8_iter_init(struct utf8_iterator * itr,char * ptr,size_t size)1571 utf8_iter_init(struct utf8_iterator *itr, char *ptr, size_t size)
1572 {
1573     itr->string = ptr;
1574     itr->curptr = ptr;
1575     itr->length = size;
1576     itr->curwidth = 0;
1577     itr->err = 0;
1578     itr->end = 0;
1579     return utf8_iter0(itr);
1580 }
1581 
1582 int
utf8_iter_first(struct utf8_iterator * itr,char * ptr)1583 utf8_iter_first(struct utf8_iterator *itr, char *ptr)
1584 {
1585     return utf8_iter_init(itr, ptr, strlen(ptr));
1586 }
1587 
1588 int
utf8_iter_next(struct utf8_iterator * itr)1589 utf8_iter_next(struct utf8_iterator *itr)
1590 {
1591     if (utf8_iter_end_p(itr))
1592 	return -1;
1593     itr->curptr += itr->curwidth;
1594     itr->length -= itr->curwidth;
1595     return utf8_iter0(itr);
1596 }
1597 
1598 
1599 /* Stores the UTF-8 representation of the Unicode character wc in r[0..5].
1600    Returns the number of bytes stored, or -1 if wc is out of range.  */
1601 int
utf8_wctomb(char * r,unsigned int wc)1602 utf8_wctomb(char *r, unsigned int wc)
1603 {
1604     int count;
1605 
1606     if (wc < 0x80)
1607 	count = 1;
1608     else if (wc < 0x800)
1609 	count = 2;
1610     else if (wc < 0x10000)
1611 	count = 3;
1612     else if (wc < 0x200000)
1613 	count = 4;
1614     else if (wc < 0x4000000)
1615 	count = 5;
1616     else if (wc <= 0x7fffffff)
1617 	count = 6;
1618     else {
1619 	errno = EILSEQ;
1620 	return -1;
1621     }
1622 
1623     switch (count) {
1624 	/* Note: code falls through cases! */
1625     case 6:
1626 	r[5] = 0x80 | (wc & 0x3f);
1627 	wc = wc >> 6;
1628 	wc |= 0x4000000;
1629     case 5:
1630 	r[4] = 0x80 | (wc & 0x3f);
1631 	wc = wc >> 6;
1632 	wc |= 0x200000;
1633     case 4:
1634 	r[3] = 0x80 | (wc & 0x3f);
1635 	wc = wc >> 6;
1636 	wc |= 0x10000;
1637     case 3:
1638 	r[2] = 0x80 | (wc & 0x3f);
1639 	wc = wc >> 6;
1640 	wc |= 0x800;
1641     case 2:
1642 	r[1] = 0x80 | (wc & 0x3f);
1643 	wc = wc >> 6;
1644 	wc |= 0xc0;
1645     case 1:
1646 	r[0] = wc;
1647     }
1648 
1649     return count;
1650 }
1651 
1652 #ifndef ENODATA
1653 # define ENODATA EINVAL
1654 #endif
1655 int
utf8_mbtowc_internal(void * data,int (* read)(void *),unsigned int * pwc)1656 utf8_mbtowc_internal(void *data, int (*read) (void *), unsigned int *pwc)
1657 {
1658     int s[4];
1659 #define nextc(n) if (((n) = read (data)) <= 0) { errno = ENODATA; return -1; }
1660 
1661     nextc(s[0]);
1662     if (s[0] < 0x80) {
1663 	*pwc = s[0];
1664 	return 1;
1665     }
1666 
1667     if (s[0] < 0xc2) {
1668 	errno = EILSEQ;
1669 	return -1;
1670     } else if (s[0] < 0xe0) {
1671 	nextc(s[1]);
1672 	if (!((s[1] ^ 0x80) < 0x40)) {
1673 	    errno = EILSEQ;
1674 	    return -1;
1675 	}
1676 	*pwc = ((unsigned int) (s[0] & 0x1f) << 6) |
1677 	    (unsigned int) (s[1] ^ 0x80);
1678 	return 2;
1679     }
1680 
1681     if (s[0] < 0xf0) {
1682 	nextc(s[1]);
1683 	nextc(s[2]);
1684 
1685 	if (!((s[1] ^ 0x80) < 0x40
1686 	      && (s[2] ^ 0x80) < 0x40 && (s[0] >= 0xe1 || s[1] >= 0xa0))) {
1687 	    errno = EILSEQ;
1688 	    return -1;
1689 	}
1690 
1691 	*pwc = ((unsigned long) (s[0] & 0x0f) << 12) |
1692 		((unsigned long) (s[1] ^ 0x80) << 6) |
1693 		(unsigned long) (s[2] ^ 0x80);
1694 
1695 	return 3;
1696     }
1697 
1698     if (s[0] < 0xf8) {
1699 	nextc(s[1]);
1700 	nextc(s[2]);
1701 	nextc(s[3]);
1702 
1703 	if (!((s[1] ^ 0x80) < 0x40 &&
1704 	      (s[2] ^ 0x80) < 0x40 &&
1705 	      (s[3] ^ 0x80) < 0x40 && (s[0] >= 0xf1 || s[1] >= 0x90))) {
1706 	    errno = EILSEQ;
1707 	    return -1;
1708 	}
1709 
1710 	*pwc = ((unsigned long) (s[0] & 0x07) << 18) |
1711 		((unsigned long) (s[1] ^ 0x80) << 12) |
1712 		((unsigned long) (s[2] ^ 0x80) << 6) |
1713 		(unsigned long) (s[3] ^ 0x80);
1714 
1715 	return 4;
1716     }
1717     errno = EILSEQ;
1718     return -1;
1719 }
1720 
1721 
1722 struct tstring {
1723     const unsigned char *ptr;
1724     size_t len;
1725 };
1726 
1727 static int
_next_char_from_string(void * data)1728 _next_char_from_string(void *data)
1729 {
1730     struct tstring *p = data;
1731     if (p->len == 0)
1732 	return 0;
1733     p->len--;
1734     return *p->ptr++;
1735 }
1736 
1737 int
utf8_mbtowc(unsigned int * pwc,const char * r,size_t len)1738 utf8_mbtowc(unsigned int *pwc, const char *r, size_t len)
1739 {
1740     struct tstring ts;
1741     ts.ptr = (const unsigned char*)r;
1742     ts.len = len ? len : utf8_char_width(r);
1743     return utf8_mbtowc_internal(&ts, _next_char_from_string, pwc);
1744 }
1745 
1746 
1747 int
utf8_symcmp(char * a,char * b)1748 utf8_symcmp(char *a, char *b)
1749 {
1750     unsigned int wa, wb;
1751 
1752     utf8_mbtowc(&wa, a, utf8_char_width(a));
1753     utf8_mbtowc(&wb, b, utf8_char_width(b));
1754     if (wa < wb)
1755 	return -1;
1756     if (wa > wb)
1757 	return 1;
1758     return 0;
1759 }
1760 
1761 int
urf8_symcasecmp(char * a,char * b)1762 urf8_symcasecmp(char *a, char *b)
1763 {
1764     unsigned int wa, wb;
1765 
1766     utf8_mbtowc(&wa, a, utf8_char_width(a));
1767     utf8_mbtowc(&wb, b, utf8_char_width(b));
1768     wa = utf8_wc_toupper(wa);
1769     wb = utf8_wc_toupper(wb);
1770     if (wa < wb)
1771 	return -1;
1772     if (wa > wb)
1773 	return 1;
1774     return 0;
1775 }
1776 
1777 int
utf8_compare(char const * a,char const * b,int ci,size_t maxlen,int (* wcsel)(unsigned))1778 utf8_compare(char const *a, char const *b,
1779 	     int ci, size_t maxlen, int (*wcsel)(unsigned))
1780 {
1781     int alen, blen;
1782     size_t an = 0, bn = 0;
1783     unsigned wa, wb;
1784 
1785     while (1) {
1786 	if (maxlen != 0 && an == maxlen)
1787 	    return 0;
1788 	if (*a == 0)
1789 	    break;
1790 
1791 	alen = utf8_char_width(a);
1792 	if (alen == 0)
1793 	    return -1;
1794 
1795 	utf8_mbtowc(&wa, a, alen);
1796 	a += alen;
1797 	an++;
1798 
1799 	if (!wcsel || wcsel(wa)) {
1800 	    if (*b == 0)
1801 		return 1;
1802 	    while (*b) {
1803 		if (maxlen != 0 && bn == maxlen)
1804 		    return 0;
1805 		blen = utf8_char_width(b);
1806 		if (blen == 0)
1807 		    return 1;
1808 		utf8_mbtowc(&wb, b, blen);
1809 		b += blen;
1810 		bn++;
1811 
1812 		if (!wcsel || wcsel(wb)) {
1813 		    if (ci == case_insensitive) {
1814 			wa = utf8_wc_toupper(wa);
1815 			wb = utf8_wc_toupper(wb);
1816 		    }
1817 		    if (wa < wb)
1818 			return -1;
1819 		    if (wa > wb)
1820 			return 1;
1821 		    break;
1822 		}
1823 	    }
1824 	}
1825     }
1826 
1827     while (*b) {
1828 	blen = utf8_char_width(b);
1829 	if (blen == 0)
1830 	    return 1;
1831 	utf8_mbtowc(&wb, b, blen);
1832 	b += blen;
1833 	if (!wcsel || wcsel(wb))
1834 	    return -1;
1835     }
1836 
1837     return 0;
1838 }
1839 
1840 int
utf8_strcmp(char const * a,char const * b)1841 utf8_strcmp(char const *a, char const *b)
1842 {
1843     return utf8_compare(a, b, case_sensitive, 0, NULL);
1844 }
1845 
1846 int
utf8_strcasecmp(char const * a,char const * b)1847 utf8_strcasecmp(char const *a, char const *b)
1848 {
1849     return utf8_compare(a, b, case_insensitive, 0, NULL);
1850 }
1851 
1852 int
utf8_strncasecmp(char const * a,char const * b,size_t maxlen)1853 utf8_strncasecmp(char const *a, char const *b, size_t maxlen)
1854 {
1855     return utf8_compare(a, b, case_insensitive, maxlen, NULL);
1856 }
1857 
1858 unsigned
utf8_wc_toupper(unsigned wc)1859 utf8_wc_toupper(unsigned wc)
1860 {
1861     int plane = (wc >> 8) & 0xFF;
1862     return uni_plane[plane] ? uni_plane[plane][wc & 0xFF].toupper : wc;
1863 }
1864 
1865 int
utf8_toupper(char * s)1866 utf8_toupper(char *s)
1867 {
1868     size_t len = strlen(s);
1869     while (*s) {
1870 	unsigned wc;
1871 	int rc = utf8_mbtowc(&wc, s, len);
1872 	if (rc <= 0)
1873 	    return 1;
1874 	if (rc != utf8_wctomb(s, utf8_wc_toupper(wc)))
1875 	    return 1;
1876 	s += rc;
1877     }
1878     return 0;
1879 }
1880 
1881 unsigned
utf8_wc_tolower(unsigned wc)1882 utf8_wc_tolower(unsigned wc)
1883 {
1884     int plane = (wc >> 8) & 0xFF;
1885     return uni_plane[plane] ? uni_plane[plane][wc & 0xFF].tolower : wc;
1886 }
1887 
1888 int
utf8_tolower(char * s)1889 utf8_tolower(char *s)
1890 {
1891     size_t len = strlen(s);
1892     while (*s) {
1893 	unsigned wc;
1894 	int rc = utf8_mbtowc(&wc, s, len);
1895 	if (rc <= 0)
1896 	    return 1;
1897 	if (rc != utf8_wctomb(s, utf8_wc_tolower(wc)))
1898 	    return 1;
1899 	s += rc;
1900     }
1901     return 0;
1902 }
1903 
1904 
1905 size_t
utf8_wc_strlen(const unsigned * s)1906 utf8_wc_strlen(const unsigned *s)
1907 {
1908     size_t len = 0;
1909     while (*s++)
1910 	len++;
1911     return len;
1912 }
1913 
1914 unsigned *
utf8_wc_strdup(const unsigned * s)1915 utf8_wc_strdup(const unsigned *s)
1916 {
1917     size_t len = utf8_wc_strlen(s) + 1;
1918     unsigned *clone = calloc(len, sizeof s[0]);
1919     if (clone)
1920 	memcpy(clone, s, len);
1921     return clone;
1922 }
1923 
1924 size_t
utf8_wc_hash_string(const unsigned * ws,size_t n_buckets)1925 utf8_wc_hash_string(const unsigned *ws, size_t n_buckets)
1926 {
1927     size_t value = 0;
1928     unsigned wc;
1929 # define ROTATE_LEFT(Value, Shift)					\
1930     ((Value) << (Shift) | (Value) >> ((sizeof (size_t) * CHAR_BIT) - (Shift)))
1931 # define HASH_ONE_CHAR(Value, Byte)		\
1932     ((Byte) + ROTATE_LEFT (Value, 16))
1933 
1934     while ((wc = *ws++))
1935 	value = HASH_ONE_CHAR(value, wc);
1936     return value % n_buckets;
1937 }
1938 
1939 int
utf8_wc_strcmp(const unsigned * a,const unsigned * b)1940 utf8_wc_strcmp(const unsigned *a, const unsigned *b)
1941 {
1942     while (*a == *b) {
1943 	if (*a == 0)
1944 	    return 0;
1945 	a++;
1946 	b++;
1947     }
1948     if (*a < *b)
1949 	return -1;
1950     if (*a > *b)
1951 	return 1;
1952     return 0;
1953 }
1954 
1955 int
utf8_wc_strncmp(const unsigned * a,const unsigned * b,size_t n)1956 utf8_wc_strncmp(const unsigned *a, const unsigned *b, size_t n)
1957 {
1958     if (n == 0)
1959 	return 0;
1960     while (*a == *b) {
1961 	if (*a == 0)
1962 	    return -1;
1963 	if (--n == 0)
1964 	    return 0;
1965 	a++;
1966 	b++;
1967     }
1968     if (*a < *b)
1969 	return -1;
1970     if (*a > *b)
1971 	return 1;
1972     return 0;
1973 }
1974 
1975 int
utf8_wc_strcasecmp(const unsigned * a,const unsigned * b)1976 utf8_wc_strcasecmp(const unsigned *a, const unsigned *b)
1977 {
1978     while (*a) {
1979 	if (*b == 0)
1980 	    return 1;
1981 	if (*a != *b) {
1982 	    unsigned wa, wb;
1983 	    wa = utf8_wc_toupper(*a);
1984 	    wb = utf8_wc_toupper(*b);
1985 
1986 	    if (wa < wb)
1987 		return -1;
1988 	    if (wa > wb)
1989 		return 1;
1990 	}
1991 	a++;
1992 	b++;
1993     }
1994     return *b ? -1 : 0;
1995 }
1996 
1997 int
utf8_wc_strncasecmp(const unsigned * a,const unsigned * b,size_t n)1998 utf8_wc_strncasecmp(const unsigned *a, const unsigned *b, size_t n)
1999 {
2000     if (n == 0)
2001 	return 0;
2002     while (*a) {
2003 	if (*b == 0)
2004 	    return 1;
2005 	if (*a != *b) {
2006 	    unsigned wa, wb;
2007 	    wa = utf8_wc_toupper(*a);
2008 	    wb = utf8_wc_toupper(*b);
2009 
2010 	    if (wa < wb)
2011 		return -1;
2012 	    if (wa > wb)
2013 		return 1;
2014 	}
2015 	if (--n == 0)
2016 	    return 0;
2017 	a++;
2018 	b++;
2019     }
2020     return *b ? -1 : 0;
2021 }
2022 
2023 const unsigned *
utf8_wc_strchr(const unsigned * str,unsigned chr)2024 utf8_wc_strchr(const unsigned *str, unsigned chr)
2025 {
2026     for (; *str; str++)
2027 	if (*str == chr)
2028 	    return str;
2029     return NULL;
2030 }
2031 
2032 const unsigned *
utf8_wc_strchr_ci(const unsigned * str,unsigned chr)2033 utf8_wc_strchr_ci(const unsigned *str, unsigned chr)
2034 {
2035     unsigned u = utf8_wc_toupper(chr);
2036     for (; *str; str++)
2037 	if (utf8_wc_toupper(*str) == u)
2038 	    return str;
2039     return NULL;
2040 }
2041 
2042 #define INIT ((size_t) -1)
2043 
2044 /* Compute the table of tagged border lengths for use in the
2045    Knuth-Morris-Pratt algorithm.
2046 */
2047 static size_t *
kmp_next(const unsigned * text,size_t text_len,const unsigned * pattern,size_t pattern_len)2048 kmp_next(const unsigned *text, size_t text_len,
2049 	 const unsigned *pattern, size_t pattern_len)
2050 {
2051     size_t *nextab;
2052     size_t i, j;
2053 
2054     if (pattern_len + 1 == 0) {
2055 	errno = ERANGE;
2056 	return NULL;
2057     }
2058 
2059     nextab = calloc(pattern_len + 1, sizeof nextab[0]);
2060     if (!nextab)
2061 	return NULL;
2062 
2063     i = 0;
2064     j = INIT;
2065     nextab[0] = j;
2066     while (i < pattern_len) {
2067 	while (j != INIT && pattern[i] != text[j])
2068 	    j = nextab[j];
2069 	i++;
2070 	j++;
2071 	if (pattern[i] == pattern[j])
2072 	    nextab[i] = nextab[j];
2073 	else
2074 	    nextab[i] = j;
2075     }
2076 
2077     return nextab;
2078 }
2079 
2080 /* Find the first occurrence of PATTERN in TEXT.
2081    Return value:
2082      strpat_found     - Pattern was found.  Unless RETURN_OFFSET is NULL, the
2083                         offset of the pattern is stored in the memory location
2084 		        it points to.
2085      strpat_not_found - Pattern was not found.
2086      strpat_error     - An error occurred.  The errno variable is set to
2087                         ERANGE if pattern is too long, or to ENOMEM if unable
2088 			to allocate memory.
2089 
2090    This implementation uses Knuth-Morris-Pratt algorithm.  If low on memory,
2091    it falls back to brute force algorithm.
2092 */
2093 unsigned const *
utf8_wc_strstr(const unsigned * text,const unsigned * pattern)2094 utf8_wc_strstr(const unsigned *text, const unsigned *pattern)
2095 {
2096     size_t i, j;
2097     unsigned const *result;
2098     size_t text_len = utf8_wc_strlen(text);
2099     size_t pattern_len = utf8_wc_strlen(pattern);
2100     size_t *nextab;
2101 
2102     errno = 0;
2103 
2104     /* Handle corner cases */
2105     if (pattern_len > text_len)
2106 	return NULL;
2107     else if (pattern_len == 1)
2108 	return utf8_wc_strchr(text, pattern[0]);
2109     else if (pattern_len == text_len) {
2110 	if (utf8_wc_strcmp(text, pattern) == 0)
2111 	    return text;
2112 	else
2113 	    return NULL;
2114     }
2115 
2116     /* Uses Knuth-Morris-Pratt algorithm for the general case */
2117     nextab = kmp_next(text, text_len, pattern, pattern_len);
2118     if (!nextab) {
2119 	/* Fall back to brute force approach */
2120 	unsigned first = pattern[0];
2121 	for (; *text; text++)
2122 	    if (*text == first) {
2123 		/* Compare with pattern's remaining units.  */
2124 		const unsigned *text_ptr = text + 1;
2125 		const unsigned *pat_ptr = pattern + 1;
2126 		for (;;) {
2127 		    if (*text_ptr != *pat_ptr)
2128 			break;
2129 		    text_ptr++;
2130 		    pat_ptr++;
2131 		    if (*pat_ptr == 0)
2132 			return text;
2133 		}
2134 	    }
2135 	return NULL;
2136     }
2137 
2138     i = j = 0;
2139     result = NULL;
2140     while (j < text_len) {
2141 	while (i != INIT && pattern[i] != text[j])
2142 	    i = nextab[i];
2143 	i++;
2144 	j++;
2145 	if (i >= pattern_len) {
2146 	    result = text + j - i;
2147 	    break;
2148 	}
2149     }
2150 
2151     free(nextab);
2152 
2153     return result;
2154 }
2155 
2156 unsigned *
utf8_wc_quote(const unsigned * s)2157 utf8_wc_quote(const unsigned *s)
2158 {
2159     size_t len = utf8_wc_strlen(s);
2160     unsigned *clone = calloc(2 * len + 1, sizeof s[0]);
2161     if (clone) {
2162 	size_t i, j;
2163 	for (i = j = 0; i < len; i++) {
2164 	    switch (s[i]) {
2165 	    case '\\':
2166 	    case '"':
2167 		clone[j++] = '\\';
2168 		/* fall through */
2169 	    default:
2170 		clone[j++] = s[i];
2171 	    }
2172 	}
2173 	clone[j] = 0;
2174 	clone = realloc(clone, (j + 1) * sizeof(clone[0]));
2175     }
2176     return clone;
2177 }
2178 
2179 int
utf8_wc_to_mbstr(const unsigned * wordbuf,size_t wordlen,char ** sptr)2180 utf8_wc_to_mbstr(const unsigned *wordbuf, size_t wordlen, char **sptr)
2181 {
2182     size_t i;
2183     size_t wbc;
2184     char *s;
2185 
2186     wbc = 0;
2187     for (i = 0; i < wordlen; i++) {
2188 	char r[6];
2189 	int rc = utf8_wctomb(r, wordbuf[i]);
2190 	if (rc <= 0)
2191 	    return -1;
2192 	wbc += rc;
2193     }
2194 
2195     s = malloc(wbc + 1);
2196     if (!s) {
2197 	errno = ENOMEM;
2198 	return -1;
2199     }
2200 
2201     wbc = 0;
2202     for (i = 0; i < wordlen; i++) {
2203 	char r[6];
2204 	int rc = utf8_wctomb(r, wordbuf[i]);
2205 	if (rc <= 0) {
2206 	    int ec = errno;
2207 	    free(s);
2208 	    errno = ec;
2209 	    return -1;
2210 	}
2211 	memcpy(s + wbc, r, rc);
2212 	wbc += rc;
2213     }
2214     s[wbc] = 0;
2215     *sptr = s;
2216     return 0;
2217 }
2218 
2219 void
utf8_wc_strupper(unsigned * str)2220 utf8_wc_strupper(unsigned *str)
2221 {
2222     for (; *str; str++)
2223 	*str = utf8_wc_toupper(*str);
2224 }
2225 
2226 void
utf8_wc_strlower(unsigned * str)2227 utf8_wc_strlower(unsigned *str)
2228 {
2229     for (; *str; str++)
2230 	*str = utf8_wc_tolower(*str);
2231 }
2232 
2233 int
utf8_mbstr_to_wc(const char * str,unsigned ** wptr,size_t * plen)2234 utf8_mbstr_to_wc(const char *str, unsigned **wptr, size_t *plen)
2235 {
2236     ssize_t sc = strlen(str);
2237     size_t len, i;
2238     unsigned *w = calloc(sizeof(w[0]), sc + 1);
2239 
2240     if (!w)
2241 	return -1;
2242     for (i = 0, len = strlen(str); len; i++) {
2243 	int rc = utf8_mbtowc(w + i, str, len);
2244 	if (rc <= 0) {
2245 	    int ec = errno;
2246 	    free(w);
2247 	    errno = ec;
2248 	    return -1;
2249 	}
2250 	str += rc;
2251 	len -= rc;
2252     }
2253     *wptr = w;
2254     if (plen)
2255 	*plen = sc;
2256     return 0;
2257 }
2258 
2259 #define ISWS(c) ((c)==' '||(c)=='\t'||(c)=='\n')
2260 
2261 int
utf8_mbstr_to_norm_wc(const char * str,unsigned ** nptr,size_t * plen)2262 utf8_mbstr_to_norm_wc(const char *str, unsigned **nptr, size_t * plen)
2263 {
2264     int inws = 0;
2265     size_t len = strlen(str);
2266     unsigned *base = calloc(len + 1, sizeof(base[0]));
2267     size_t i = 0;
2268 
2269     if (!base)
2270 	return -1;
2271 
2272     while (len > 0) {
2273 	unsigned wc;
2274 	int rc = utf8_mbtowc(&wc, str, len);
2275 	if (rc <= 0)
2276 	    return -1;
2277 	str += rc;
2278 	len -= rc;
2279 	if (rc == 1 && ISWS(wc)) {
2280 	    if (!inws) {
2281 		wc = ' ';
2282 		inws = 1;
2283 	    } else
2284 		continue;
2285 	} else
2286 	    inws = 0;
2287 	base[i++] = wc;
2288     }
2289     base[i++] = 0;
2290     *nptr = realloc(base, i * sizeof(base[0]));
2291     if (plen)
2292 	*plen = i;
2293     return 0;
2294 }
2295 
2296 int
utf8_quote(const char * str,char ** sptr)2297 utf8_quote(const char *str, char **sptr)
2298 {
2299     int rc;
2300     unsigned *ws, *ret;
2301 
2302     rc = utf8_mbstr_to_wc(str, &ws, NULL);
2303     if (rc)
2304 	return rc;
2305     ret = utf8_wc_quote(ws);
2306     if (ret) {
2307 	rc = utf8_wc_to_mbstr(ret, utf8_wc_strlen(ret), sptr);
2308 	free(ret);
2309     } else {
2310 	errno = ENOMEM;
2311 	rc = -1;
2312     }
2313     return rc;
2314 }
2315 
2316 int
utf8_table_check(unsigned wc,unsigned const * start,int const * count,size_t size)2317 utf8_table_check(unsigned wc,
2318 		 unsigned const *start, int const *count, size_t size)
2319 {
2320     const unsigned *l = start;
2321     const unsigned *r = start + size;
2322     const unsigned *s = NULL;
2323 
2324     if (wc == 0)
2325 	return 0;
2326 
2327     while (l < r) {
2328 	s = l + ((r - l) >> 1);
2329 
2330 	if (*s <= wc) {
2331 	    l = s + 1;
2332 	} else {
2333 	    r = s;
2334 	}
2335     }
2336 
2337     --l;
2338 
2339     return (wc < l[0] + count[l - start]);
2340 }
2341