View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  
21  package org.apache.directory.api.ldap.model.schema;
22  
23  
24  import java.io.IOException;
25  
26  import org.apache.directory.api.util.Strings;
27  import org.apache.directory.api.util.exception.InvalidCharacterException;
28  
29  
30  /**
31   * 
32   * This class implements the 6 steps described in RFC 4518
33   *
34   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
35   */
36  public final class PrepareString
37  {
38      /** A flag used to lowercase chars during the map process */
39      private static final boolean CASE_SENSITIVE = true;
40  
41      /** A flag used to keep casing during the map process */
42      private static final boolean IGNORE_CASE = false;
43  
44      /** All the possible combining marks */
45      private static final char[][] COMBINING_MARKS = new char[][]
46          {
47              { 0x0300, 0x034F },
48              { 0x0360, 0x036F },
49              { 0x0483, 0x0486 },
50              { 0x0488, 0x0489 },
51              { 0x0591, 0x05A1 },
52              { 0x05A3, 0x05B9 },
53              { 0x05BB, 0x05BC },
54              { 0x05BF, 0x05BF },
55              { 0x05C1, 0x05C2 },
56              { 0x05C4, 0x05C4 },
57              { 0x064B, 0x0655 },
58              { 0x0670, 0x0670 },
59              { 0x06D6, 0x06DC },
60              { 0x06DE, 0x06E4 },
61              { 0x06E7, 0x06E8 },
62              { 0x06EA, 0x06ED },
63              { 0x0711, 0x0711 },
64              { 0x0730, 0x074A },
65              { 0x07A6, 0x07B0 },
66              { 0x0901, 0x0903 },
67              { 0x093C, 0x093C },
68              { 0x093E, 0x094F },
69              { 0x0951, 0x0954 },
70              { 0x0962, 0x0963 },
71              { 0x0981, 0x0983 },
72              { 0x09BC, 0x09BC },
73              { 0x09BE, 0x09C4 },
74              { 0x09C7, 0x09C8 },
75              { 0x09CB, 0x09CD },
76              { 0x09D7, 0x09D7 },
77              { 0x09E2, 0x09E3 },
78              { 0x0A02, 0x0A02 },
79              { 0x0A3C, 0x0A3C },
80              { 0x0A3E, 0x0A42 },
81              { 0x0A47, 0x0A48 },
82              { 0x0A4B, 0x0A4D },
83              { 0x0A70, 0x0A71 },
84              { 0x0A81, 0x0A83 },
85              { 0x0ABC, 0x0ABC },
86              { 0x0ABE, 0x0AC5 },
87              { 0x0AC7, 0x0AC9 },
88              { 0x0ACB, 0x0ACD },
89              { 0x0B01, 0x0B03 },
90              { 0x0B3C, 0x0B3C },
91              { 0x0B3E, 0x0B43 },
92              { 0x0B47, 0x0B48 },
93              { 0x0B4B, 0x0B4D },
94              { 0x0B56, 0x0B57 },
95              { 0x0B82, 0x0B82 },
96              { 0x0BBE, 0x0BC2 },
97              { 0x0BC6, 0x0BC8 },
98              { 0x0BCA, 0x0BCD },
99              { 0x0BD7, 0x0BD7 },
100             { 0x0C01, 0x0C03 },
101             { 0x0C3E, 0x0C44 },
102             { 0x0C46, 0x0C48 },
103             { 0x0C4A, 0x0C4D },
104             { 0x0C55, 0x0C56 },
105             { 0x0C82, 0x0C83 },
106             { 0x0CBE, 0x0CC4 },
107             { 0x0CC6, 0x0CC8 },
108             { 0x0CCA, 0x0CCD },
109             { 0x0CD5, 0x0CD6 },
110             { 0x0D02, 0x0D03 },
111             { 0x0D3E, 0x0D43 },
112             { 0x0D46, 0x0D48 },
113             { 0x0D4A, 0x0D4D },
114             { 0x0D57, 0x0D57 },
115             { 0x0D82, 0x0D83 },
116             { 0x0DCA, 0x0DCA },
117             { 0x0DCF, 0x0DD4 },
118             { 0x0DD6, 0x0DD6 },
119             { 0x0DD8, 0x0DDF },
120             { 0x0DF2, 0x0DF3 },
121             { 0x0E31, 0x0E31 },
122             { 0x0E34, 0x0E3A },
123             { 0x0E47, 0x0E4E },
124             { 0x0EB1, 0x0EB1 },
125             { 0x0EB4, 0x0EB9 },
126             { 0x0EBB, 0x0EBC },
127             { 0x0EC8, 0x0ECD },
128             { 0x0F18, 0x0F19 },
129             { 0x0F35, 0x0F35 },
130             { 0x0F37, 0x0F37 },
131             { 0x0F39, 0x0F39 },
132             { 0x0F3E, 0x0F3F },
133             { 0x0F71, 0x0F84 },
134             { 0x0F86, 0x0F87 },
135             { 0x0F90, 0x0F97 },
136             { 0x0F99, 0x0FBC },
137             { 0x0FC6, 0x0FC6 },
138             { 0x102C, 0x1032 },
139             { 0x1036, 0x1039 },
140             { 0x1056, 0x1059 },
141             { 0x1712, 0x1714 },
142             { 0x1732, 0x1734 },
143             { 0x1752, 0x1753 },
144             { 0x1772, 0x1773 },
145             { 0x17B4, 0x17D3 },
146             { 0x180B, 0x180D },
147             { 0x18A9, 0x18A9 },
148             { 0x20D0, 0x20EA },
149             { 0x302A, 0x302F },
150             { 0x3099, 0x309A },
151             { 0xFB1E, 0xFB1E },
152             { 0xFE00, 0xFE0F },
153             { 0xFE20, 0xFE23 }
154     };
155 
156     /**
157      * The type of String we have to normalize
158      */
159     public enum StringType
160     {
161         NOT_STRING,
162         NUMERIC_STRING,
163         CASE_EXACT,
164         CASE_EXACT_IA5,
165         CASE_IGNORE_IA5,
166         CASE_IGNORE_LIST,
167         CASE_IGNORE,
168         DIRECTORY_STRING,
169         TELEPHONE_NUMBER,
170         WORD
171     }
172 
173 
174     /**
175      * A private constructor, to avoid instance creation of this static class.
176      */
177     private PrepareString()
178     {
179         // Do nothing
180     }
181 
182 
183     /**
184      * Tells if a char is a combining mark.
185      *
186      * @param c The char to check
187      * @return true if the char is a combining mark, false otherwise
188      */
189     private static boolean isCombiningMark( char c )
190     {
191         if ( c < COMBINING_MARKS[0][0] )
192         {
193             return false;
194         }
195 
196         for ( char[] interval : COMBINING_MARKS )
197         {
198             if ( ( c >= interval[0] ) && ( c <= interval[1] ) )
199             {
200                 return true;
201             }
202         }
203 
204         return false;
205     }
206 
207 
208     /**
209     *
210     * We have to go through 6 steps :
211     *
212     * 1) Transcode
213     * 2) Map
214     * 3) Normalize
215     * 4) Prohibit
216     * 5) Bidi
217     * 6) Insignifiant Character Handling
218     *
219     * The first step is already done, the step (3) is not done.
220     *
221     * @param str The String to normalize
222     * @param type The string type
223     * @return A normalized string.
224     * @throws IOException
225     */
226     public static String normalize( String str, StringType type ) throws IOException
227     {
228         switch ( type )
229         {
230             case NUMERIC_STRING:
231                 return insignifiantCharNumericString( str );
232 
233             case TELEPHONE_NUMBER:
234                 return insignifiantCharTelephoneNumber( str );
235 
236             case CASE_EXACT:
237             case CASE_EXACT_IA5:
238             case DIRECTORY_STRING:
239                 try
240                 {
241                     return insignifiantSpacesStringAscii( str, CASE_SENSITIVE );
242                 }
243                 catch ( Exception e )
244                 {
245                     return insignifiantSpacesString( str, CASE_SENSITIVE );
246                 }
247 
248             case CASE_IGNORE_IA5:
249             case CASE_IGNORE_LIST:
250             case CASE_IGNORE:
251                 try
252                 {
253                     return insignifiantSpacesStringAscii( str, IGNORE_CASE );
254                 }
255                 catch ( Exception e )
256                 {
257                     return insignifiantSpacesString( str, IGNORE_CASE );
258                 }
259 
260             case WORD:
261                 return str;
262 
263             default:
264                 return str;
265 
266         }
267     }
268 
269 
270     /**
271      * Execute the mapping step of the string preparation :
272      * - suppress useless chars
273      * - transform to spaces
274      * - lowercase
275      * 
276      * @param c The char to map
277      * @param array The array which will collect the transformed char
278      * @param pos The current position in the target
279      * @param lowerCase A mask to lowercase the char, if necessary
280      * @return The transformed StringBuilder
281      */
282     // CHECKSTYLE:OFF
283     private static int map( char[] src, char[] target, char lowerCase )
284     {
285         int limit = 0;
286 
287         for ( char c : src )
288         {
289             switch ( c )
290             {
291                 case 0x0000:
292                 case 0x0001:
293                 case 0x0002:
294                 case 0x0003:
295                 case 0x0004:
296                 case 0x0005:
297                 case 0x0006:
298                 case 0x0007:
299                 case 0x0008:
300                     break;
301 
302                 case 0x0009:
303                 case 0x000A:
304                 case 0x000B:
305                 case 0x000C:
306                 case 0x000D:
307                     target[limit++] = ( char ) 0x20;
308                     break;
309 
310                 case 0x000E:
311                 case 0x000F:
312                 case 0x0010:
313                 case 0x0011:
314                 case 0x0012:
315                 case 0x0013:
316                 case 0x0014:
317                 case 0x0015:
318                 case 0x0016:
319                 case 0x0017:
320                 case 0x0018:
321                 case 0x0019:
322                 case 0x001A:
323                 case 0x001B:
324                 case 0x001C:
325                 case 0x001D:
326                 case 0x001E:
327                 case 0x001F:
328                     break;
329 
330                 case 0x0041:
331                 case 0x0042:
332                 case 0x0043:
333                 case 0x0044:
334                 case 0x0045:
335                 case 0x0046:
336                 case 0x0047:
337                 case 0x0048:
338                 case 0x0049:
339                 case 0x004A:
340                 case 0x004B:
341                 case 0x004C:
342                 case 0x004D:
343                 case 0x004E:
344                 case 0x004F:
345                 case 0x0050:
346                 case 0x0051:
347                 case 0x0052:
348                 case 0x0053:
349                 case 0x0054:
350                 case 0x0055:
351                 case 0x0056:
352                 case 0x0057:
353                 case 0x0058:
354                 case 0x0059:
355                 case 0x005A:
356                     target[limit++] = ( char ) ( c | lowerCase );
357                     break;
358 
359                 case 0x007F:
360                 case 0x0080:
361                 case 0x0081:
362                 case 0x0082:
363                 case 0x0083:
364                 case 0x0084:
365                     break;
366 
367                 case 0x0085:
368                     target[limit] = ( char ) 0x20;
369                     break;
370 
371                 case 0x0086:
372                 case 0x0087:
373                 case 0x0088:
374                 case 0x0089:
375                 case 0x008A:
376                 case 0x008B:
377                 case 0x008C:
378                 case 0x008D:
379                 case 0x008E:
380                 case 0x008F:
381                 case 0x0090:
382                 case 0x0091:
383                 case 0x0092:
384                 case 0x0093:
385                 case 0x0094:
386                 case 0x0095:
387                 case 0x0096:
388                 case 0x0097:
389                 case 0x0098:
390                 case 0x0099:
391                 case 0x009A:
392                 case 0x009B:
393                 case 0x009C:
394                 case 0x009D:
395                 case 0x009E:
396                 case 0x009F:
397                     break;
398 
399                 case 0x00A0:
400                     target[limit++] = ( char ) 0x20;
401                     break;
402 
403                 case 0x00AD:
404                     break;
405 
406                 case 0x00B5:
407                     target[limit++] = ( char ) 0x03BC;
408                     break;
409 
410                 case 0x00C0:
411                 case 0x00C1:
412                 case 0x00C2:
413                 case 0x00C3:
414                 case 0x00C4:
415                 case 0x00C5:
416                 case 0x00C6:
417                 case 0x00C7:
418                 case 0x00C8:
419                 case 0x00C9:
420                 case 0x00CA:
421                 case 0x00CB:
422                 case 0x00CC:
423                 case 0x00CD:
424                 case 0x00CE:
425                 case 0x00CF:
426                 case 0x00D0:
427                 case 0x00D1:
428                 case 0x00D2:
429                 case 0x00D3:
430                 case 0x00D4:
431                 case 0x00D5:
432                 case 0x00D6:
433                 case 0x00D8:
434                 case 0x00D9:
435                 case 0x00DA:
436                 case 0x00DB:
437                 case 0x00DC:
438                 case 0x00DD:
439                 case 0x00DE:
440                     target[limit++] = ( char ) ( c | lowerCase );
441                     break;
442 
443                 case 0x00DF:
444                     target[limit++] = ( char ) 0x0073;
445                     target[limit++] = ( char ) 0x0073;
446                     break;
447 
448                 case 0x0100:
449                     target[limit++] = ( char ) 0x0101;
450                     break;
451 
452                 case 0x0102:
453                     target[limit++] = ( char ) 0x0103;
454                     break;
455 
456                 case 0x0104:
457                     target[limit++] = 0x0105;
458                     break;
459 
460                 case 0x0106:
461                     target[limit++] = 0x0107;
462                     break;
463 
464                 case 0x0108:
465                     target[limit++] = 0x0109;
466                     break;
467 
468                 case 0x010A:
469                     target[limit++] = 0x010B;
470                     break;
471 
472                 case 0x010C:
473                     target[limit++] = 0x010D;
474                     break;
475 
476                 case 0x010E:
477                     target[limit++] = 0x010F;
478                     break;
479 
480                 case 0x0110:
481                     target[limit++] = 0x0111;
482                     break;
483 
484                 case 0x0112:
485                     target[limit++] = 0x0113;
486                     break;
487 
488                 case 0x0114:
489                     target[limit++] = 0x0115;
490                     break;
491 
492                 case 0x0116:
493                     target[limit++] = 0x0117;
494                     break;
495 
496                 case 0x0118:
497                     target[limit++] = 0x0119;
498                     break;
499 
500                 case 0x011A:
501                     target[limit++] = 0x011B;
502                     break;
503 
504                 case 0x011C:
505                     target[limit++] = 0x011D;
506                     break;
507 
508                 case 0x011E:
509                     target[limit++] = 0x011F;
510                     break;
511 
512                 case 0x0120:
513                     target[limit++] = 0x0121;
514                     break;
515 
516                 case 0x0122:
517                     target[limit++] = 0x0123;
518                     break;
519 
520                 case 0x0124:
521                     target[limit++] = 0x0125;
522                     break;
523 
524                 case 0x0126:
525                     target[limit++] = 0x0127;
526                     break;
527 
528                 case 0x0128:
529                     target[limit++] = 0x0129;
530                     break;
531 
532                 case 0x012A:
533                     target[limit++] = 0x012B;
534                     break;
535 
536                 case 0x012C:
537                     target[limit++] = 0x012D;
538                     break;
539 
540                 case 0x012E:
541                     target[limit++] = 0x012F;
542                     break;
543 
544                 case 0x0130:
545                     target[limit++] = 0x0069;
546                     target[limit++] = 0x0307;
547                     break;
548 
549                 case 0x0132:
550                     target[limit++] = 0x0133;
551                     break;
552 
553                 case 0x0134:
554                     target[limit++] = 0x0135;
555                     break;
556 
557                 case 0x0136:
558                     target[limit++] = 0x0137;
559                     break;
560 
561                 case 0x0139:
562                     target[limit++] = 0x013A;
563                     break;
564 
565                 case 0x013B:
566                     target[limit++] = 0x013C;
567                     break;
568 
569                 case 0x013D:
570                     target[limit++] = 0x013E;
571                     break;
572 
573                 case 0x013F:
574                     target[limit++] = 0x0140;
575                     break;
576 
577                 case 0x0141:
578                     target[limit++] = 0x0142;
579                     break;
580 
581                 case 0x0143:
582                     target[limit++] = 0x0144;
583                     break;
584 
585                 case 0x0145:
586                     target[limit++] = 0x0146;
587                     break;
588 
589                 case 0x0147:
590                     target[limit++] = 0x0148;
591                     break;
592 
593                 case 0x0149:
594                     target[limit++] = 0x02BC;
595                     target[limit++] = 0x006E;
596                     break;
597 
598                 case 0x014A:
599                     target[limit++] = 0x014B;
600                     break;
601 
602                 case 0x014C:
603                     target[limit++] = 0x014D;
604                     break;
605 
606                 case 0x014E:
607                     target[limit++] = 0x014F;
608                     break;
609 
610                 case 0x0150:
611                     target[limit++] = 0x0151;
612                     break;
613 
614                 case 0x0152:
615                     target[limit++] = 0x0153;
616                     break;
617 
618                 case 0x0154:
619                     target[limit++] = 0x0155;
620                     break;
621 
622                 case 0x0156:
623                     target[limit++] = 0x0157;
624                     break;
625 
626                 case 0x0158:
627                     target[limit++] = 0x0159;
628                     break;
629 
630                 case 0x015A:
631                     target[limit++] = 0x015B;
632                     break;
633 
634                 case 0x015C:
635                     target[limit++] = 0x015D;
636                     break;
637 
638                 case 0x015E:
639                     target[limit++] = 0x015F;
640                     break;
641 
642                 case 0x0160:
643                     target[limit++] = 0x0161;
644                     break;
645 
646                 case 0x0162:
647                     target[limit++] = 0x0163;
648                     break;
649 
650                 case 0x0164:
651                     target[limit++] = 0x0165;
652                     break;
653 
654                 case 0x0166:
655                     target[limit++] = 0x0167;
656                     break;
657 
658                 case 0x0168:
659                     target[limit++] = 0x0169;
660                     break;
661 
662                 case 0x016A:
663                     target[limit++] = 0x016B;
664                     break;
665 
666                 case 0x016C:
667                     target[limit++] = 0x016D;
668                     break;
669 
670                 case 0x016E:
671                     target[limit++] = 0x016F;
672                     break;
673 
674                 case 0x0170:
675                     target[limit++] = 0x0171;
676                     break;
677 
678                 case 0x0172:
679                     target[limit++] = 0x0173;
680                     break;
681 
682                 case 0x0174:
683                     target[limit++] = 0x0175;
684                     break;
685 
686                 case 0x0176:
687                     target[limit++] = 0x0177;
688                     break;
689 
690                 case 0x0178:
691                     target[limit++] = 0x00FF;
692                     break;
693 
694                 case 0x0179:
695                     target[limit++] = 0x017A;
696                     break;
697 
698                 case 0x017B:
699                     target[limit++] = 0x017C;
700                     break;
701 
702                 case 0x017D:
703                     target[limit++] = 0x017E;
704                     break;
705 
706                 case 0x017F:
707                     target[limit++] = 0x0073;
708                     break;
709 
710                 case 0x0181:
711                     target[limit++] = 0x0253;
712                     break;
713 
714                 case 0x0182:
715                     target[limit++] = 0x0183;
716                     break;
717 
718                 case 0x0184:
719                     target[limit++] = 0x0185;
720                     break;
721 
722                 case 0x0186:
723                     target[limit++] = 0x0254;
724                     break;
725 
726                 case 0x0187:
727                     target[limit++] = 0x0188;
728                     break;
729 
730                 case 0x0189:
731                     target[limit++] = 0x0256;
732                     break;
733 
734                 case 0x018A:
735                     target[limit++] = 0x0257;
736                     break;
737 
738                 case 0x018B:
739                     target[limit++] = 0x018C;
740                     break;
741 
742                 case 0x018E:
743                     target[limit++] = 0x01DD;
744                     break;
745 
746                 case 0x018F:
747                     target[limit++] = 0x0259;
748                     break;
749 
750                 case 0x0190:
751                     target[limit++] = 0x025B;
752                     break;
753 
754                 case 0x0191:
755                     target[limit++] = 0x0192;
756                     break;
757 
758                 case 0x0193:
759                     target[limit++] = 0x0260;
760                     break;
761 
762                 case 0x0194:
763                     target[limit++] = 0x0263;
764                     break;
765 
766                 case 0x0196:
767                     target[limit++] = 0x0269;
768                     break;
769 
770                 case 0x0197:
771                     target[limit++] = 0x0268;
772                     break;
773 
774                 case 0x0198:
775                     target[limit++] = 0x0199;
776                     break;
777 
778                 case 0x019C:
779                     target[limit++] = 0x026F;
780                     break;
781 
782                 case 0x019D:
783                     target[limit++] = 0x0272;
784                     break;
785 
786                 case 0x019F:
787                     target[limit++] = 0x0275;
788                     break;
789 
790                 case 0x01A0:
791                     target[limit++] = 0x01A1;
792                     break;
793 
794                 case 0x01A2:
795                     target[limit++] = 0x01A3;
796                     break;
797 
798                 case 0x01A4:
799                     target[limit++] = 0x01A5;
800                     break;
801 
802                 case 0x01A6:
803                     target[limit++] = 0x0280;
804                     break;
805 
806                 case 0x01A7:
807                     target[limit++] = 0x01A8;
808                     break;
809 
810                 case 0x01A9:
811                     target[limit++] = 0x0283;
812                     break;
813 
814                 case 0x01AC:
815                     target[limit++] = 0x01AD;
816                     break;
817 
818                 case 0x01AE:
819                     target[limit++] = 0x0288;
820                     break;
821 
822                 case 0x01AF:
823                     target[limit++] = 0x01B0;
824                     break;
825 
826                 case 0x01B1:
827                     target[limit++] = 0x028A;
828                     break;
829 
830                 case 0x01B2:
831                     target[limit++] = 0x028B;
832                     break;
833 
834                 case 0x01B3:
835                     target[limit++] = 0x01B4;
836                     break;
837 
838                 case 0x01B5:
839                     target[limit++] = 0x01B6;
840                     break;
841 
842                 case 0x01B7:
843                     target[limit++] = 0x0292;
844                     break;
845 
846                 case 0x01B8:
847                     target[limit++] = 0x01B9;
848                     break;
849 
850                 case 0x01BC:
851                     target[limit++] = 0x01BD;
852                     break;
853 
854                 case 0x01C4:
855                     target[limit++] = 0x01C6;
856                     break;
857 
858                 case 0x01C5:
859                     target[limit++] = 0x01C6;
860                     break;
861 
862                 case 0x01C7:
863                     target[limit++] = 0x01C9;
864                     break;
865 
866                 case 0x01C8:
867                     target[limit++] = 0x01C9;
868                     break;
869 
870                 case 0x01CA:
871                     target[limit++] = 0x01CC;
872                     break;
873 
874                 case 0x01CB:
875                     target[limit++] = 0x01CC;
876                     break;
877 
878                 case 0x01CD:
879                     target[limit++] = 0x01CE;
880                     break;
881 
882                 case 0x01CF:
883                     target[limit++] = 0x01D0;
884                     break;
885 
886                 case 0x01D1:
887                     target[limit++] = 0x01D2;
888                     break;
889 
890                 case 0x01D3:
891                     target[limit++] = 0x01D4;
892                     break;
893 
894                 case 0x01D5:
895                     target[limit++] = 0x01D6;
896                     break;
897 
898                 case 0x01D7:
899                     target[limit++] = 0x01D8;
900                     break;
901 
902                 case 0x01D9:
903                     target[limit++] = 0x01DA;
904                     break;
905 
906                 case 0x01DB:
907                     target[limit++] = 0x01DC;
908                     break;
909 
910                 case 0x01DE:
911                     target[limit++] = 0x01DF;
912                     break;
913 
914                 case 0x01E0:
915                     target[limit++] = 0x01E1;
916                     break;
917 
918                 case 0x01E2:
919                     target[limit++] = 0x01E3;
920                     break;
921 
922                 case 0x01E4:
923                     target[limit++] = 0x01E5;
924                     break;
925 
926                 case 0x01E6:
927                     target[limit++] = 0x01E7;
928                     break;
929 
930                 case 0x01E8:
931                     target[limit++] = 0x01E9;
932                     break;
933 
934                 case 0x01EA:
935                     target[limit++] = 0x01EB;
936                     break;
937 
938                 case 0x01EC:
939                     target[limit++] = 0x01ED;
940                     break;
941 
942                 case 0x01EE:
943                     target[limit++] = 0x01EF;
944                     break;
945 
946                 case 0x01F0:
947                     target[limit++] = 0x006A;
948                     target[limit++] = 0x030C;
949                     break;
950 
951                 case 0x01F1:
952                     target[limit++] = 0x01F3;
953                     break;
954 
955                 case 0x01F2:
956                     target[limit++] = 0x01F3;
957                     break;
958 
959                 case 0x01F4:
960                     target[limit++] = 0x01F5;
961                     break;
962 
963                 case 0x01F6:
964                     target[limit++] = 0x0195;
965                     break;
966 
967                 case 0x01F7:
968                     target[limit++] = 0x01BF;
969                     break;
970 
971                 case 0x01F8:
972                     target[limit++] = 0x01F9;
973                     break;
974 
975                 case 0x01FA:
976                     target[limit++] = 0x01FB;
977                     break;
978 
979                 case 0x01FC:
980                     target[limit++] = 0x01FD;
981                     break;
982 
983                 case 0x01FE:
984                     target[limit++] = 0x01FF;
985                     break;
986 
987                 case 0x0200:
988                     target[limit++] = 0x0201;
989                     break;
990 
991                 case 0x0202:
992                     target[limit++] = 0x0203;
993                     break;
994 
995                 case 0x0204:
996                     target[limit++] = 0x0205;
997                     break;
998 
999                 case 0x0206:
1000                     target[limit++] = 0x0207;
1001                     break;
1002 
1003                 case 0x0208:
1004                     target[limit++] = 0x0209;
1005                     break;
1006 
1007                 case 0x020A:
1008                     target[limit++] = 0x020B;
1009                     break;
1010 
1011                 case 0x020C:
1012                     target[limit++] = 0x020D;
1013                     break;
1014 
1015                 case 0x020E:
1016                     target[limit++] = 0x020F;
1017                     break;
1018 
1019                 case 0x0210:
1020                     target[limit++] = 0x0211;
1021                     break;
1022 
1023                 case 0x0212:
1024                     target[limit++] = 0x0213;
1025                     break;
1026 
1027                 case 0x0214:
1028                     target[limit++] = 0x0215;
1029                     break;
1030 
1031                 case 0x0216:
1032                     target[limit++] = 0x0217;
1033                     break;
1034 
1035                 case 0x0218:
1036                     target[limit++] = 0x0219;
1037                     break;
1038 
1039                 case 0x021A:
1040                     target[limit++] = 0x021B;
1041                     break;
1042 
1043                 case 0x021C:
1044                     target[limit++] = 0x021D;
1045                     break;
1046 
1047                 case 0x021E:
1048                     target[limit++] = 0x021F;
1049                     break;
1050 
1051                 case 0x0220:
1052                     target[limit++] = 0x019E;
1053                     break;
1054 
1055                 case 0x0222:
1056                     target[limit++] = 0x0223;
1057                     break;
1058 
1059                 case 0x0224:
1060                     target[limit++] = 0x0225;
1061                     break;
1062 
1063                 case 0x0226:
1064                     target[limit++] = 0x0227;
1065                     break;
1066 
1067                 case 0x0228:
1068                     target[limit++] = 0x0229;
1069                     break;
1070 
1071                 case 0x022A:
1072                     target[limit++] = 0x022B;
1073                     break;
1074 
1075                 case 0x022C:
1076                     target[limit++] = 0x022D;
1077                     break;
1078 
1079                 case 0x022E:
1080                     target[limit++] = 0x022F;
1081                     break;
1082 
1083                 case 0x0230:
1084                     target[limit++] = 0x0231;
1085                     break;
1086 
1087                 case 0x0232:
1088                     target[limit++] = 0x0233;
1089                     break;
1090 
1091                 case 0x0345:
1092                     target[limit++] = 0x03B9;
1093                     break;
1094 
1095                 case 0x034F:
1096                     break;
1097 
1098                 case 0x037A:
1099                     target[limit++] = 0x0020;
1100                     target[limit++] = 0x03B9;
1101                     break;
1102 
1103                 case 0x0386:
1104                     target[limit++] = 0x03AC;
1105                     break;
1106 
1107                 case 0x0388:
1108                     target[limit++] = 0x03AD;
1109                     break;
1110 
1111                 case 0x0389:
1112                     target[limit++] = 0x03AE;
1113                     break;
1114 
1115                 case 0x038A:
1116                     target[limit++] = 0x03AF;
1117                     break;
1118 
1119                 case 0x038C:
1120                     target[limit++] = 0x03CC;
1121                     break;
1122 
1123                 case 0x038E:
1124                     target[limit++] = 0x03CD;
1125                     break;
1126 
1127                 case 0x038F:
1128                     target[limit++] = 0x03CE;
1129                     break;
1130 
1131                 case 0x0390:
1132                     target[limit++] = 0x03B9;
1133                     target[limit++] = 0x0308;
1134                     target[limit++] = 0x0301;
1135                     break;
1136 
1137                 case 0x0391:
1138                     target[limit++] = 0x03B1;
1139                     break;
1140 
1141                 case 0x0392:
1142                     target[limit++] = 0x03B2;
1143                     break;
1144 
1145                 case 0x0393:
1146                     target[limit++] = 0x03B3;
1147                     break;
1148 
1149                 case 0x0394:
1150                     target[limit++] = 0x03B4;
1151                     break;
1152 
1153                 case 0x0395:
1154                     target[limit++] = 0x03B5;
1155                     break;
1156 
1157                 case 0x0396:
1158                     target[limit++] = 0x03B6;
1159                     break;
1160 
1161                 case 0x0397:
1162                     target[limit++] = 0x03B7;
1163                     break;
1164 
1165                 case 0x0398:
1166                     target[limit++] = 0x03B8;
1167                     break;
1168 
1169                 case 0x0399:
1170                     target[limit++] = 0x03B9;
1171                     break;
1172 
1173                 case 0x039A:
1174                     target[limit++] = 0x03BA;
1175                     break;
1176 
1177                 case 0x039B:
1178                     target[limit++] = 0x03BB;
1179                     break;
1180 
1181                 case 0x039C:
1182                     target[limit++] = 0x03BC;
1183                     break;
1184 
1185                 case 0x039D:
1186                     target[limit++] = 0x03BD;
1187                     break;
1188 
1189                 case 0x039E:
1190                     target[limit++] = 0x03BE;
1191                     break;
1192 
1193                 case 0x039F:
1194                     target[limit++] = 0x03BF;
1195                     break;
1196 
1197                 case 0x03A0:
1198                     target[limit++] = 0x03C0;
1199                     break;
1200 
1201                 case 0x03A1:
1202                     target[limit++] = 0x03C1;
1203                     break;
1204 
1205                 case 0x03A3:
1206                     target[limit++] = 0x03C3;
1207                     break;
1208 
1209                 case 0x03A4:
1210                     target[limit++] = 0x03C4;
1211                     break;
1212 
1213                 case 0x03A5:
1214                     target[limit++] = 0x03C5;
1215                     break;
1216 
1217                 case 0x03A6:
1218                     target[limit++] = 0x03C6;
1219                     break;
1220 
1221                 case 0x03A7:
1222                     target[limit++] = 0x03C7;
1223                     break;
1224 
1225                 case 0x03A8:
1226                     target[limit++] = 0x03C8;
1227                     break;
1228 
1229                 case 0x03A9:
1230                     target[limit++] = 0x03C9;
1231                     break;
1232 
1233                 case 0x03AA:
1234                     target[limit++] = 0x03CA;
1235                     break;
1236 
1237                 case 0x03AB:
1238                     target[limit++] = 0x03CB;
1239                     break;
1240 
1241                 case 0x03B0:
1242                     target[limit++] = 0x03C5;
1243                     target[limit++] = 0x0308;
1244                     target[limit++] = 0x0301;
1245                     break;
1246 
1247                 case 0x03C2:
1248                     target[limit++] = 0x03C3;
1249                     break;
1250 
1251                 case 0x03D0:
1252                     target[limit++] = 0x03B2;
1253                     break;
1254 
1255                 case 0x03D1:
1256                     target[limit++] = 0x03B8;
1257                     break;
1258 
1259                 case 0x03D2:
1260                     target[limit++] = 0x03C5;
1261                     break;
1262 
1263                 case 0x03D3:
1264                     target[limit++] = 0x03CD;
1265                     break;
1266 
1267                 case 0x03D4:
1268                     target[limit++] = 0x03CB;
1269                     break;
1270 
1271                 case 0x03D5:
1272                     target[limit++] = 0x03C6;
1273                     break;
1274 
1275                 case 0x03D6:
1276                     target[limit++] = 0x03C0;
1277                     break;
1278 
1279                 case 0x03D8:
1280                     target[limit++] = 0x03D9;
1281                     break;
1282 
1283                 case 0x03DA:
1284                     target[limit++] = 0x03DB;
1285                     break;
1286 
1287                 case 0x03DC:
1288                     target[limit++] = 0x03DD;
1289                     break;
1290 
1291                 case 0x03DE:
1292                     target[limit++] = 0x03DF;
1293                     break;
1294 
1295                 case 0x03E0:
1296                     target[limit++] = 0x03E1;
1297                     break;
1298 
1299                 case 0x03E2:
1300                     target[limit++] = 0x03E3;
1301                     break;
1302 
1303                 case 0x03E4:
1304                     target[limit++] = 0x03E5;
1305                     break;
1306 
1307                 case 0x03E6:
1308                     target[limit++] = 0x03E7;
1309                     break;
1310 
1311                 case 0x03E8:
1312                     target[limit++] = 0x03E9;
1313                     break;
1314 
1315                 case 0x03EA:
1316                     target[limit++] = 0x03EB;
1317                     break;
1318 
1319                 case 0x03EC:
1320                     target[limit++] = 0x03ED;
1321                     break;
1322 
1323                 case 0x03EE:
1324                     target[limit++] = 0x03EF;
1325                     break;
1326 
1327                 case 0x03F0:
1328                     target[limit++] = 0x03BA;
1329                     break;
1330 
1331                 case 0x03F1:
1332                     target[limit++] = 0x03C1;
1333                     break;
1334 
1335                 case 0x03F2:
1336                     target[limit++] = 0x03C3;
1337                     break;
1338 
1339                 case 0x03F4:
1340                     target[limit++] = 0x03B8;
1341                     break;
1342 
1343                 case 0x03F5:
1344                     target[limit++] = 0x03B5;
1345                     break;
1346 
1347                 case 0x0400:
1348                     target[limit++] = 0x0450;
1349                     break;
1350 
1351                 case 0x0401:
1352                     target[limit++] = 0x0451;
1353                     break;
1354 
1355                 case 0x0402:
1356                     target[limit++] = 0x0452;
1357                     break;
1358 
1359                 case 0x0403:
1360                     target[limit++] = 0x0453;
1361                     break;
1362 
1363                 case 0x0404:
1364                     target[limit++] = 0x0454;
1365                     break;
1366 
1367                 case 0x0405:
1368                     target[limit++] = 0x0455;
1369                     break;
1370 
1371                 case 0x0406:
1372                     target[limit++] = 0x0456;
1373                     break;
1374 
1375                 case 0x0407:
1376                     target[limit++] = 0x0457;
1377                     break;
1378 
1379                 case 0x0408:
1380                     target[limit++] = 0x0458;
1381                     break;
1382 
1383                 case 0x0409:
1384                     target[limit++] = 0x0459;
1385                     break;
1386 
1387                 case 0x040A:
1388                     target[limit++] = 0x045A;
1389                     break;
1390 
1391                 case 0x040B:
1392                     target[limit++] = 0x045B;
1393                     break;
1394 
1395                 case 0x040C:
1396                     target[limit++] = 0x045C;
1397                     break;
1398 
1399                 case 0x040D:
1400                     target[limit++] = 0x045D;
1401                     break;
1402 
1403                 case 0x040E:
1404                     target[limit++] = 0x045E;
1405                     break;
1406 
1407                 case 0x040F:
1408                     target[limit++] = 0x045F;
1409                     break;
1410 
1411                 case 0x0410:
1412                     target[limit++] = 0x0430;
1413                     break;
1414 
1415                 case 0x0411:
1416                     target[limit++] = 0x0431;
1417                     break;
1418 
1419                 case 0x0412:
1420                     target[limit++] = 0x0432;
1421                     break;
1422 
1423                 case 0x0413:
1424                     target[limit++] = 0x0433;
1425                     break;
1426 
1427                 case 0x0414:
1428                     target[limit++] = 0x0434;
1429                     break;
1430 
1431                 case 0x0415:
1432                     target[limit++] = 0x0435;
1433                     break;
1434 
1435                 case 0x0416:
1436                     target[limit++] = 0x0436;
1437                     break;
1438 
1439                 case 0x0417:
1440                     target[limit++] = 0x0437;
1441                     break;
1442 
1443                 case 0x0418:
1444                     target[limit++] = 0x0438;
1445                     break;
1446 
1447                 case 0x0419:
1448                     target[limit++] = 0x0439;
1449                     break;
1450 
1451                 case 0x041A:
1452                     target[limit++] = 0x043A;
1453                     break;
1454 
1455                 case 0x041B:
1456                     target[limit++] = 0x043B;
1457                     break;
1458 
1459                 case 0x041C:
1460                     target[limit++] = 0x043C;
1461                     break;
1462 
1463                 case 0x041D:
1464                     target[limit++] = 0x043D;
1465                     break;
1466 
1467                 case 0x041E:
1468                     target[limit++] = 0x043E;
1469                     break;
1470 
1471                 case 0x041F:
1472                     target[limit++] = 0x043F;
1473                     break;
1474 
1475                 case 0x0420:
1476                     target[limit++] = 0x0440;
1477                     break;
1478 
1479                 case 0x0421:
1480                     target[limit++] = 0x0441;
1481                     break;
1482 
1483                 case 0x0422:
1484                     target[limit++] = 0x0442;
1485                     break;
1486 
1487                 case 0x0423:
1488                     target[limit++] = 0x0443;
1489                     break;
1490 
1491                 case 0x0424:
1492                     target[limit++] = 0x0444;
1493                     break;
1494 
1495                 case 0x0425:
1496                     target[limit++] = 0x0445;
1497                     break;
1498 
1499                 case 0x0426:
1500                     target[limit++] = 0x0446;
1501                     break;
1502 
1503                 case 0x0427:
1504                     target[limit++] = 0x0447;
1505                     break;
1506 
1507                 case 0x0428:
1508                     target[limit++] = 0x0448;
1509                     break;
1510 
1511                 case 0x0429:
1512                     target[limit++] = 0x0449;
1513                     break;
1514 
1515                 case 0x042A:
1516                     target[limit++] = 0x044A;
1517                     break;
1518 
1519                 case 0x042B:
1520                     target[limit++] = 0x044B;
1521                     break;
1522 
1523                 case 0x042C:
1524                     target[limit++] = 0x044C;
1525                     break;
1526 
1527                 case 0x042D:
1528                     target[limit++] = 0x044D;
1529                     break;
1530 
1531                 case 0x042E:
1532                     target[limit++] = 0x044E;
1533                     break;
1534 
1535                 case 0x042F:
1536                     target[limit++] = 0x044F;
1537                     break;
1538 
1539                 case 0x0460:
1540                     target[limit++] = 0x0461;
1541                     break;
1542 
1543                 case 0x0462:
1544                     target[limit++] = 0x0463;
1545                     break;
1546 
1547                 case 0x0464:
1548                     target[limit++] = 0x0465;
1549                     break;
1550 
1551                 case 0x0466:
1552                     target[limit++] = 0x0467;
1553                     break;
1554 
1555                 case 0x0468:
1556                     target[limit++] = 0x0469;
1557                     break;
1558 
1559                 case 0x046A:
1560                     target[limit++] = 0x046B;
1561                     break;
1562 
1563                 case 0x046C:
1564                     target[limit++] = 0x046D;
1565                     break;
1566 
1567                 case 0x046E:
1568                     target[limit++] = 0x046F;
1569                     break;
1570 
1571                 case 0x0470:
1572                     target[limit++] = 0x0471;
1573                     break;
1574 
1575                 case 0x0472:
1576                     target[limit++] = 0x0473;
1577                     break;
1578 
1579                 case 0x0474:
1580                     target[limit++] = 0x0475;
1581                     break;
1582 
1583                 case 0x0476:
1584                     target[limit++] = 0x0477;
1585                     break;
1586 
1587                 case 0x0478:
1588                     target[limit++] = 0x0479;
1589                     break;
1590 
1591                 case 0x047A:
1592                     target[limit++] = 0x047B;
1593                     break;
1594 
1595                 case 0x047C:
1596                     target[limit++] = 0x047D;
1597                     break;
1598 
1599                 case 0x047E:
1600                     target[limit++] = 0x047F;
1601                     break;
1602 
1603                 case 0x0480:
1604                     target[limit++] = 0x0481;
1605                     break;
1606 
1607                 case 0x048A:
1608                     target[limit++] = 0x048B;
1609                     break;
1610 
1611                 case 0x048C:
1612                     target[limit++] = 0x048D;
1613                     break;
1614 
1615                 case 0x048E:
1616                     target[limit++] = 0x048F;
1617                     break;
1618 
1619                 case 0x0490:
1620                     target[limit++] = 0x0491;
1621                     break;
1622 
1623                 case 0x0492:
1624                     target[limit++] = 0x0493;
1625                     break;
1626 
1627                 case 0x0494:
1628                     target[limit++] = 0x0495;
1629                     break;
1630 
1631                 case 0x0496:
1632                     target[limit++] = 0x0497;
1633                     break;
1634 
1635                 case 0x0498:
1636                     target[limit++] = 0x0499;
1637                     break;
1638 
1639                 case 0x049A:
1640                     target[limit++] = 0x049B;
1641                     break;
1642 
1643                 case 0x049C:
1644                     target[limit++] = 0x049D;
1645                     break;
1646 
1647                 case 0x049E:
1648                     target[limit++] = 0x049F;
1649                     break;
1650 
1651                 case 0x04A0:
1652                     target[limit++] = 0x04A1;
1653                     break;
1654 
1655                 case 0x04A2:
1656                     target[limit++] = 0x04A3;
1657                     break;
1658 
1659                 case 0x04A4:
1660                     target[limit++] = 0x04A5;
1661                     break;
1662 
1663                 case 0x04A6:
1664                     target[limit++] = 0x04A7;
1665                     break;
1666 
1667                 case 0x04A8:
1668                     target[limit++] = 0x04A9;
1669                     break;
1670 
1671                 case 0x04AA:
1672                     target[limit++] = 0x04AB;
1673                     break;
1674 
1675                 case 0x04AC:
1676                     target[limit++] = 0x04AD;
1677                     break;
1678 
1679                 case 0x04AE:
1680                     target[limit++] = 0x04AF;
1681                     break;
1682 
1683                 case 0x04B0:
1684                     target[limit++] = 0x04B1;
1685                     break;
1686 
1687                 case 0x04B2:
1688                     target[limit++] = 0x04B3;
1689                     break;
1690 
1691                 case 0x04B4:
1692                     target[limit++] = 0x04B5;
1693                     break;
1694 
1695                 case 0x04B6:
1696                     target[limit++] = 0x04B7;
1697                     break;
1698 
1699                 case 0x04B8:
1700                     target[limit++] = 0x04B9;
1701                     break;
1702 
1703                 case 0x04BA:
1704                     target[limit++] = 0x04BB;
1705                     break;
1706 
1707                 case 0x04BC:
1708                     target[limit++] = 0x04BD;
1709                     break;
1710 
1711                 case 0x04BE:
1712                     target[limit++] = 0x04BF;
1713                     break;
1714 
1715                 case 0x04C1:
1716                     target[limit++] = 0x04C2;
1717                     break;
1718 
1719                 case 0x04C3:
1720                     target[limit++] = 0x04C4;
1721                     break;
1722 
1723                 case 0x04C5:
1724                     target[limit++] = 0x04C6;
1725                     break;
1726 
1727                 case 0x04C7:
1728                     target[limit++] = 0x04C8;
1729                     break;
1730 
1731                 case 0x04C9:
1732                     target[limit++] = 0x04CA;
1733                     break;
1734 
1735                 case 0x04CB:
1736                     target[limit++] = 0x04CC;
1737                     break;
1738 
1739                 case 0x04CD:
1740                     target[limit++] = 0x04CE;
1741                     break;
1742 
1743                 case 0x04D0:
1744                     target[limit++] = 0x04D1;
1745                     break;
1746 
1747                 case 0x04D2:
1748                     target[limit++] = 0x04D3;
1749                     break;
1750 
1751                 case 0x04D4:
1752                     target[limit++] = 0x04D5;
1753                     break;
1754 
1755                 case 0x04D6:
1756                     target[limit++] = 0x04D7;
1757                     break;
1758 
1759                 case 0x04D8:
1760                     target[limit++] = 0x04D9;
1761                     break;
1762 
1763                 case 0x04DA:
1764                     target[limit++] = 0x04DB;
1765                     break;
1766 
1767                 case 0x04DC:
1768                     target[limit++] = 0x04DD;
1769                     break;
1770 
1771                 case 0x04DE:
1772                     target[limit++] = 0x04DF;
1773                     break;
1774 
1775                 case 0x04E0:
1776                     target[limit++] = 0x04E1;
1777                     break;
1778 
1779                 case 0x04E2:
1780                     target[limit++] = 0x04E3;
1781                     break;
1782 
1783                 case 0x04E4:
1784                     target[limit++] = 0x04E5;
1785                     break;
1786 
1787                 case 0x04E6:
1788                     target[limit++] = 0x04E7;
1789                     break;
1790 
1791                 case 0x04E8:
1792                     target[limit++] = 0x04E9;
1793                     break;
1794 
1795                 case 0x04EA:
1796                     target[limit++] = 0x04EB;
1797                     break;
1798 
1799                 case 0x04EC:
1800                     target[limit++] = 0x04ED;
1801                     break;
1802 
1803                 case 0x04EE:
1804                     target[limit++] = 0x04EF;
1805                     break;
1806 
1807                 case 0x04F0:
1808                     target[limit++] = 0x04F1;
1809                     break;
1810 
1811                 case 0x04F2:
1812                     target[limit++] = 0x04F3;
1813                     break;
1814 
1815                 case 0x04F4:
1816                     target[limit++] = 0x04F5;
1817                     break;
1818 
1819                 case 0x04F8:
1820                     target[limit++] = 0x04F9;
1821                     break;
1822 
1823                 case 0x0500:
1824                     target[limit++] = 0x0501;
1825                     break;
1826 
1827                 case 0x0502:
1828                     target[limit++] = 0x0503;
1829                     break;
1830 
1831                 case 0x0504:
1832                     target[limit++] = 0x0505;
1833                     break;
1834 
1835                 case 0x0506:
1836                     target[limit++] = 0x0507;
1837                     break;
1838 
1839                 case 0x0508:
1840                     target[limit++] = 0x0509;
1841                     break;
1842 
1843                 case 0x050A:
1844                     target[limit++] = 0x050B;
1845                     break;
1846 
1847                 case 0x050C:
1848                     target[limit++] = 0x050D;
1849                     break;
1850 
1851                 case 0x050E:
1852                     target[limit++] = 0x050F;
1853                     break;
1854 
1855                 case 0x0531:
1856                     target[limit++] = 0x0561;
1857                     break;
1858 
1859                 case 0x0532:
1860                     target[limit++] = 0x0562;
1861                     break;
1862 
1863                 case 0x0533:
1864                     target[limit++] = 0x0563;
1865                     break;
1866 
1867                 case 0x0534:
1868                     target[limit++] = 0x0564;
1869                     break;
1870 
1871                 case 0x0535:
1872                     target[limit++] = 0x0565;
1873                     break;
1874 
1875                 case 0x0536:
1876                     target[limit++] = 0x0566;
1877                     break;
1878 
1879                 case 0x0537:
1880                     target[limit++] = 0x0567;
1881                     break;
1882 
1883                 case 0x0538:
1884                     target[limit++] = 0x0568;
1885                     break;
1886 
1887                 case 0x0539:
1888                     target[limit++] = 0x0569;
1889                     break;
1890 
1891                 case 0x053A:
1892                     target[limit++] = 0x056A;
1893                     break;
1894 
1895                 case 0x053B:
1896                     target[limit++] = 0x056B;
1897                     break;
1898 
1899                 case 0x053C:
1900                     target[limit++] = 0x056C;
1901                     break;
1902 
1903                 case 0x053D:
1904                     target[limit++] = 0x056D;
1905                     break;
1906 
1907                 case 0x053E:
1908                     target[limit++] = 0x056E;
1909                     break;
1910 
1911                 case 0x053F:
1912                     target[limit++] = 0x056F;
1913                     break;
1914 
1915                 case 0x0540:
1916                     target[limit++] = 0x0570;
1917                     break;
1918 
1919                 case 0x0541:
1920                     target[limit++] = 0x0571;
1921                     break;
1922 
1923                 case 0x0542:
1924                     target[limit++] = 0x0572;
1925                     break;
1926 
1927                 case 0x0543:
1928                     target[limit++] = 0x0573;
1929                     break;
1930 
1931                 case 0x0544:
1932                     target[limit++] = 0x0574;
1933                     break;
1934 
1935                 case 0x0545:
1936                     target[limit++] = 0x0575;
1937                     break;
1938 
1939                 case 0x0546:
1940                     target[limit++] = 0x0576;
1941                     break;
1942 
1943                 case 0x0547:
1944                     target[limit++] = 0x0577;
1945                     break;
1946 
1947                 case 0x0548:
1948                     target[limit++] = 0x0578;
1949                     break;
1950 
1951                 case 0x0549:
1952                     target[limit++] = 0x0579;
1953                     break;
1954 
1955                 case 0x054A:
1956                     target[limit++] = 0x057A;
1957                     break;
1958 
1959                 case 0x054B:
1960                     target[limit++] = 0x057B;
1961                     break;
1962 
1963                 case 0x054C:
1964                     target[limit++] = 0x057C;
1965                     break;
1966 
1967                 case 0x054D:
1968                     target[limit++] = 0x057D;
1969                     break;
1970 
1971                 case 0x054E:
1972                     target[limit++] = 0x057E;
1973                     break;
1974 
1975                 case 0x054F:
1976                     target[limit++] = 0x057F;
1977                     break;
1978 
1979                 case 0x0550:
1980                     target[limit++] = 0x0580;
1981                     break;
1982 
1983                 case 0x0551:
1984                     target[limit++] = 0x0581;
1985                     break;
1986 
1987                 case 0x0552:
1988                     target[limit++] = 0x0582;
1989                     break;
1990 
1991                 case 0x0553:
1992                     target[limit++] = 0x0583;
1993                     break;
1994 
1995                 case 0x0554:
1996                     target[limit++] = 0x0584;
1997                     break;
1998 
1999                 case 0x0555:
2000                     target[limit++] = 0x0585;
2001                     break;
2002 
2003                 case 0x0556:
2004                     target[limit++] = 0x0586;
2005                     break;
2006 
2007                 case 0x0587:
2008                     target[limit++] = 0x0565;
2009                     target[limit++] = 0x0582;
2010                     break;
2011 
2012                 case 0x06DD:
2013                     break;
2014 
2015                 case 0x070F:
2016                     break;
2017 
2018                 case 0x1680:
2019                     target[limit++] = 0x0020;
2020                     break;
2021 
2022                 case 0x1806:
2023                     break;
2024 
2025                 case 0x180B:
2026                 case 0x180C:
2027                 case 0x180D:
2028                 case 0x180E:
2029                     break;
2030 
2031                 case 0x1E00:
2032                     target[limit++] = 0x1E01;
2033                     break;
2034 
2035                 case 0x1E02:
2036                     target[limit++] = 0x1E03;
2037                     break;
2038 
2039                 case 0x1E04:
2040                     target[limit++] = 0x1E05;
2041                     break;
2042 
2043                 case 0x1E06:
2044                     target[limit++] = 0x1E07;
2045                     break;
2046 
2047                 case 0x1E08:
2048                     target[limit++] = 0x1E09;
2049                     break;
2050 
2051                 case 0x1E0A:
2052                     target[limit++] = 0x1E0B;
2053                     break;
2054 
2055                 case 0x1E0C:
2056                     target[limit++] = 0x1E0D;
2057                     break;
2058 
2059                 case 0x1E0E:
2060                     target[limit++] = 0x1E0F;
2061                     break;
2062 
2063                 case 0x1E10:
2064                     target[limit++] = 0x1E11;
2065                     break;
2066 
2067                 case 0x1E12:
2068                     target[limit++] = 0x1E13;
2069                     break;
2070 
2071                 case 0x1E14:
2072                     target[limit++] = 0x1E15;
2073                     break;
2074 
2075                 case 0x1E16:
2076                     target[limit++] = 0x1E17;
2077                     break;
2078 
2079                 case 0x1E18:
2080                     target[limit++] = 0x1E19;
2081                     break;
2082 
2083                 case 0x1E1A:
2084                     target[limit++] = 0x1E1B;
2085                     break;
2086 
2087                 case 0x1E1C:
2088                     target[limit++] = 0x1E1D;
2089                     break;
2090 
2091                 case 0x1E1E:
2092                     target[limit++] = 0x1E1F;
2093                     break;
2094 
2095                 case 0x1E20:
2096                     target[limit++] = 0x1E21;
2097                     break;
2098 
2099                 case 0x1E22:
2100                     target[limit++] = 0x1E23;
2101                     break;
2102 
2103                 case 0x1E24:
2104                     target[limit++] = 0x1E25;
2105                     break;
2106 
2107                 case 0x1E26:
2108                     target[limit++] = 0x1E27;
2109                     break;
2110 
2111                 case 0x1E28:
2112                     target[limit++] = 0x1E29;
2113                     break;
2114 
2115                 case 0x1E2A:
2116                     target[limit++] = 0x1E2B;
2117                     break;
2118 
2119                 case 0x1E2C:
2120                     target[limit++] = 0x1E2D;
2121                     break;
2122 
2123                 case 0x1E2E:
2124                     target[limit++] = 0x1E2F;
2125                     break;
2126 
2127                 case 0x1E30:
2128                     target[limit++] = 0x1E31;
2129                     break;
2130 
2131                 case 0x1E32:
2132                     target[limit++] = 0x1E33;
2133                     break;
2134 
2135                 case 0x1E34:
2136                     target[limit++] = 0x1E35;
2137                     break;
2138 
2139                 case 0x1E36:
2140                     target[limit++] = 0x1E37;
2141                     break;
2142 
2143                 case 0x1E38:
2144                     target[limit++] = 0x1E39;
2145                     break;
2146 
2147                 case 0x1E3A:
2148                     target[limit++] = 0x1E3B;
2149                     break;
2150 
2151                 case 0x1E3C:
2152                     target[limit++] = 0x1E3D;
2153                     break;
2154 
2155                 case 0x1E3E:
2156                     target[limit++] = 0x1E3F;
2157                     break;
2158 
2159                 case 0x1E40:
2160                     target[limit++] = 0x1E41;
2161                     break;
2162 
2163                 case 0x1E42:
2164                     target[limit++] = 0x1E43;
2165                     break;
2166 
2167                 case 0x1E44:
2168                     target[limit++] = 0x1E45;
2169                     break;
2170 
2171                 case 0x1E46:
2172                     target[limit++] = 0x1E47;
2173                     break;
2174 
2175                 case 0x1E48:
2176                     target[limit++] = 0x1E49;
2177                     break;
2178 
2179                 case 0x1E4A:
2180                     target[limit++] = 0x1E4B;
2181                     break;
2182 
2183                 case 0x1E4C:
2184                     target[limit++] = 0x1E4D;
2185                     break;
2186 
2187                 case 0x1E4E:
2188                     target[limit++] = 0x1E4F;
2189                     break;
2190 
2191                 case 0x1E50:
2192                     target[limit++] = 0x1E51;
2193                     break;
2194 
2195                 case 0x1E52:
2196                     target[limit++] = 0x1E53;
2197                     break;
2198 
2199                 case 0x1E54:
2200                     target[limit++] = 0x1E55;
2201                     break;
2202 
2203                 case 0x1E56:
2204                     target[limit++] = 0x1E57;
2205                     break;
2206 
2207                 case 0x1E58:
2208                     target[limit++] = 0x1E59;
2209                     break;
2210 
2211                 case 0x1E5A:
2212                     target[limit++] = 0x1E5B;
2213                     break;
2214 
2215                 case 0x1E5C:
2216                     target[limit++] = 0x1E5D;
2217                     break;
2218 
2219                 case 0x1E5E:
2220                     target[limit++] = 0x1E5F;
2221                     break;
2222 
2223                 case 0x1E60:
2224                     target[limit++] = 0x1E61;
2225                     break;
2226 
2227                 case 0x1E62:
2228                     target[limit++] = 0x1E63;
2229                     break;
2230 
2231                 case 0x1E64:
2232                     target[limit++] = 0x1E65;
2233                     break;
2234 
2235                 case 0x1E66:
2236                     target[limit++] = 0x1E67;
2237                     break;
2238 
2239                 case 0x1E68:
2240                     target[limit++] = 0x1E69;
2241                     break;
2242 
2243                 case 0x1E6A:
2244                     target[limit++] = 0x1E6B;
2245                     break;
2246 
2247                 case 0x1E6C:
2248                     target[limit++] = 0x1E6D;
2249                     break;
2250 
2251                 case 0x1E6E:
2252                     target[limit++] = 0x1E6F;
2253                     break;
2254 
2255                 case 0x1E70:
2256                     target[limit++] = 0x1E71;
2257                     break;
2258 
2259                 case 0x1E72:
2260                     target[limit++] = 0x1E73;
2261                     break;
2262 
2263                 case 0x1E74:
2264                     target[limit++] = 0x1E75;
2265                     break;
2266 
2267                 case 0x1E76:
2268                     target[limit++] = 0x1E77;
2269                     break;
2270 
2271                 case 0x1E78:
2272                     target[limit++] = 0x1E79;
2273                     break;
2274 
2275                 case 0x1E7A:
2276                     target[limit++] = 0x1E7B;
2277                     break;
2278 
2279                 case 0x1E7C:
2280                     target[limit++] = 0x1E7D;
2281                     break;
2282 
2283                 case 0x1E7E:
2284                     target[limit++] = 0x1E7F;
2285                     break;
2286 
2287                 case 0x1E80:
2288                     target[limit++] = 0x1E81;
2289                     break;
2290 
2291                 case 0x1E82:
2292                     target[limit++] = 0x1E83;
2293                     break;
2294 
2295                 case 0x1E84:
2296                     target[limit++] = 0x1E85;
2297                     break;
2298 
2299                 case 0x1E86:
2300                     target[limit++] = 0x1E87;
2301                     break;
2302 
2303                 case 0x1E88:
2304                     target[limit++] = 0x1E89;
2305                     break;
2306 
2307                 case 0x1E8A:
2308                     target[limit++] = 0x1E8B;
2309                     break;
2310 
2311                 case 0x1E8C:
2312                     target[limit++] = 0x1E8D;
2313                     break;
2314 
2315                 case 0x1E8E:
2316                     target[limit++] = 0x1E8F;
2317                     break;
2318 
2319                 case 0x1E90:
2320                     target[limit++] = 0x1E91;
2321                     break;
2322 
2323                 case 0x1E92:
2324                     target[limit++] = 0x1E93;
2325                     break;
2326 
2327                 case 0x1E94:
2328                     target[limit++] = 0x1E95;
2329                     break;
2330 
2331                 case 0x1E96:
2332                     target[limit++] = 0x0068;
2333                     target[limit++] = 0x0331;
2334                     break;
2335 
2336                 case 0x1E97:
2337                     target[limit++] = 0x0074;
2338                     target[limit++] = 0x0308;
2339                     break;
2340 
2341                 case 0x1E98:
2342                     target[limit++] = 0x0077;
2343                     target[limit++] = 0x030A;
2344                     break;
2345 
2346                 case 0x1E99:
2347                     target[limit++] = 0x0079;
2348                     target[limit++] = 0x030A;
2349                     break;
2350 
2351                 case 0x1E9A:
2352                     target[limit++] = 0x0061;
2353                     target[limit++] = 0x02BE;
2354                     break;
2355 
2356                 case 0x1E9B:
2357                     target[limit++] = 0x1E61;
2358                     break;
2359 
2360                 case 0x1EA0:
2361                     target[limit++] = 0x1EA1;
2362                     break;
2363 
2364                 case 0x1EA2:
2365                     target[limit++] = 0x1EA3;
2366                     break;
2367 
2368                 case 0x1EA4:
2369                     target[limit++] = 0x1EA5;
2370                     break;
2371 
2372                 case 0x1EA6:
2373                     target[limit++] = 0x1EA7;
2374                     break;
2375 
2376                 case 0x1EA8:
2377                     target[limit++] = 0x1EA9;
2378                     break;
2379 
2380                 case 0x1EAA:
2381                     target[limit++] = 0x1EAB;
2382                     break;
2383 
2384                 case 0x1EAC:
2385                     target[limit++] = 0x1EAD;
2386                     break;
2387 
2388                 case 0x1EAE:
2389                     target[limit++] = 0x1EAF;
2390                     break;
2391 
2392                 case 0x1EB0:
2393                     target[limit++] = 0x1EB1;
2394                     break;
2395 
2396                 case 0x1EB2:
2397                     target[limit++] = 0x1EB3;
2398                     break;
2399 
2400                 case 0x1EB4:
2401                     target[limit++] = 0x1EB5;
2402                     break;
2403 
2404                 case 0x1EB6:
2405                     target[limit++] = 0x1EB7;
2406                     break;
2407 
2408                 case 0x1EB8:
2409                     target[limit++] = 0x1EB9;
2410                     break;
2411 
2412                 case 0x1EBA:
2413                     target[limit++] = 0x1EBB;
2414                     break;
2415 
2416                 case 0x1EBC:
2417                     target[limit++] = 0x1EBD;
2418                     break;
2419 
2420                 case 0x1EBE:
2421                     target[limit++] = 0x1EBF;
2422                     break;
2423 
2424                 case 0x1EC0:
2425                     target[limit++] = 0x1EC1;
2426                     break;
2427 
2428                 case 0x1EC2:
2429                     target[limit++] = 0x1EC3;
2430                     break;
2431 
2432                 case 0x1EC4:
2433                     target[limit++] = 0x1EC5;
2434                     break;
2435 
2436                 case 0x1EC6:
2437                     target[limit++] = 0x1EC7;
2438                     break;
2439 
2440                 case 0x1EC8:
2441                     target[limit++] = 0x1EC9;
2442                     break;
2443 
2444                 case 0x1ECA:
2445                     target[limit++] = 0x1ECB;
2446                     break;
2447 
2448                 case 0x1ECC:
2449                     target[limit++] = 0x1ECD;
2450                     break;
2451 
2452                 case 0x1ECE:
2453                     target[limit++] = 0x1ECF;
2454                     break;
2455 
2456                 case 0x1ED0:
2457                     target[limit++] = 0x1ED1;
2458                     break;
2459 
2460                 case 0x1ED2:
2461                     target[limit++] = 0x1ED3;
2462                     break;
2463 
2464                 case 0x1ED4:
2465                     target[limit++] = 0x1ED5;
2466                     break;
2467 
2468                 case 0x1ED6:
2469                     target[limit++] = 0x1ED7;
2470                     break;
2471 
2472                 case 0x1ED8:
2473                     target[limit++] = 0x1ED9;
2474                     break;
2475 
2476                 case 0x1EDA:
2477                     target[limit++] = 0x1EDB;
2478                     break;
2479 
2480                 case 0x1EDC:
2481                     target[limit++] = 0x1EDD;
2482                     break;
2483 
2484                 case 0x1EDE:
2485                     target[limit++] = 0x1EDF;
2486                     break;
2487 
2488                 case 0x1EE0:
2489                     target[limit++] = 0x1EE1;
2490                     break;
2491 
2492                 case 0x1EE2:
2493                     target[limit++] = 0x1EE3;
2494                     break;
2495 
2496                 case 0x1EE4:
2497                     target[limit++] = 0x1EE5;
2498                     break;
2499 
2500                 case 0x1EE6:
2501                     target[limit++] = 0x1EE7;
2502                     break;
2503 
2504                 case 0x1EE8:
2505                     target[limit++] = 0x1EE9;
2506                     break;
2507 
2508                 case 0x1EEA:
2509                     target[limit++] = 0x1EEB;
2510                     break;
2511 
2512                 case 0x1EEC:
2513                     target[limit++] = 0x1EED;
2514                     break;
2515 
2516                 case 0x1EEE:
2517                     target[limit++] = 0x1EEF;
2518                     break;
2519 
2520                 case 0x1EF0:
2521                     target[limit++] = 0x1EF1;
2522                     break;
2523 
2524                 case 0x1EF2:
2525                     target[limit++] = 0x1EF3;
2526                     break;
2527 
2528                 case 0x1EF4:
2529                     target[limit++] = 0x1EF5;
2530                     break;
2531 
2532                 case 0x1EF6:
2533                     target[limit++] = 0x1EF7;
2534                     break;
2535 
2536                 case 0x1EF8:
2537                     target[limit++] = 0x1EF9;
2538                     break;
2539 
2540                 case 0x1F08:
2541                     target[limit++] = 0x1F00;
2542                     break;
2543 
2544                 case 0x1F09:
2545                     target[limit++] = 0x1F01;
2546                     break;
2547 
2548                 case 0x1F0A:
2549                     target[limit++] = 0x1F02;
2550                     break;
2551 
2552                 case 0x1F0B:
2553                     target[limit++] = 0x1F03;
2554                     break;
2555 
2556                 case 0x1F0C:
2557                     target[limit++] = 0x1F04;
2558                     break;
2559 
2560                 case 0x1F0D:
2561                     target[limit++] = 0x1F05;
2562                     break;
2563 
2564                 case 0x1F0E:
2565                     target[limit++] = 0x1F06;
2566                     break;
2567 
2568                 case 0x1F0F:
2569                     target[limit++] = 0x1F07;
2570                     break;
2571 
2572                 case 0x1F18:
2573                     target[limit++] = 0x1F10;
2574                     break;
2575 
2576                 case 0x1F19:
2577                     target[limit++] = 0x1F11;
2578                     break;
2579 
2580                 case 0x1F1A:
2581                     target[limit++] = 0x1F12;
2582                     break;
2583 
2584                 case 0x1F1B:
2585                     target[limit++] = 0x1F13;
2586                     break;
2587 
2588                 case 0x1F1C:
2589                     target[limit++] = 0x1F14;
2590                     break;
2591 
2592                 case 0x1F1D:
2593                     target[limit++] = 0x1F15;
2594                     break;
2595 
2596                 case 0x1F28:
2597                     target[limit++] = 0x1F20;
2598                     break;
2599 
2600                 case 0x1F29:
2601                     target[limit++] = 0x1F21;
2602                     break;
2603 
2604                 case 0x1F2A:
2605                     target[limit++] = 0x1F22;
2606                     break;
2607 
2608                 case 0x1F2B:
2609                     target[limit++] = 0x1F23;
2610                     break;
2611 
2612                 case 0x1F2C:
2613                     target[limit++] = 0x1F24;
2614                     break;
2615 
2616                 case 0x1F2D:
2617                     target[limit++] = 0x1F25;
2618                     break;
2619 
2620                 case 0x1F2E:
2621                     target[limit++] = 0x1F26;
2622                     break;
2623 
2624                 case 0x1F2F:
2625                     target[limit++] = 0x1F27;
2626                     break;
2627 
2628                 case 0x1F38:
2629                     target[limit++] = 0x1F30;
2630                     break;
2631 
2632                 case 0x1F39:
2633                     target[limit++] = 0x1F31;
2634                     break;
2635 
2636                 case 0x1F3A:
2637                     target[limit++] = 0x1F32;
2638                     break;
2639 
2640                 case 0x1F3B:
2641                     target[limit++] = 0x1F33;
2642                     break;
2643 
2644                 case 0x1F3C:
2645                     target[limit++] = 0x1F34;
2646                     break;
2647 
2648                 case 0x1F3D:
2649                     target[limit++] = 0x1F35;
2650                     break;
2651 
2652                 case 0x1F3E:
2653                     target[limit++] = 0x1F36;
2654                     break;
2655 
2656                 case 0x1F3F:
2657                     target[limit++] = 0x1F37;
2658                     break;
2659 
2660                 case 0x1F48:
2661                     target[limit++] = 0x1F40;
2662                     break;
2663 
2664                 case 0x1F49:
2665                     target[limit++] = 0x1F41;
2666                     break;
2667 
2668                 case 0x1F4A:
2669                     target[limit++] = 0x1F42;
2670                     break;
2671 
2672                 case 0x1F4B:
2673                     target[limit++] = 0x1F43;
2674                     break;
2675 
2676                 case 0x1F4C:
2677                     target[limit++] = 0x1F44;
2678                     break;
2679 
2680                 case 0x1F4D:
2681                     target[limit++] = 0x1F45;
2682                     break;
2683 
2684                 case 0x1F50:
2685                     target[limit++] = 0x03C5;
2686                     target[limit++] = 0x0313;
2687                     break;
2688 
2689                 case 0x1F52:
2690                     target[limit++] = 0x03C5;
2691                     target[limit++] = 0x0313;
2692                     target[limit++] = 0x0300;
2693                     break;
2694 
2695                 case 0x1F54:
2696                     target[limit++] = 0x03C5;
2697                     target[limit++] = 0x0313;
2698                     target[limit++] = 0x0301;
2699                     break;
2700 
2701                 case 0x1F56:
2702                     target[limit++] = 0x03C5;
2703                     target[limit++] = 0x0313;
2704                     target[limit++] = 0x0342;
2705                     break;
2706 
2707                 case 0x1F59:
2708                     target[limit++] = 0x1F51;
2709                     break;
2710 
2711                 case 0x1F5B:
2712                     target[limit++] = 0x1F53;
2713                     break;
2714 
2715                 case 0x1F5D:
2716                     target[limit++] = 0x1F55;
2717                     break;
2718 
2719                 case 0x1F5F:
2720                     target[limit++] = 0x1F57;
2721                     break;
2722 
2723                 case 0x1F68:
2724                     target[limit++] = 0x1F60;
2725                     break;
2726 
2727                 case 0x1F69:
2728                     target[limit++] = 0x1F61;
2729                     break;
2730 
2731                 case 0x1F6A:
2732                     target[limit++] = 0x1F62;
2733                     break;
2734 
2735                 case 0x1F6B:
2736                     target[limit++] = 0x1F63;
2737                     break;
2738 
2739                 case 0x1F6C:
2740                     target[limit++] = 0x1F64;
2741                     break;
2742 
2743                 case 0x1F6D:
2744                     target[limit++] = 0x1F65;
2745                     break;
2746 
2747                 case 0x1F6E:
2748                     target[limit++] = 0x1F66;
2749                     break;
2750 
2751                 case 0x1F6F:
2752                     target[limit++] = 0x1F67;
2753                     break;
2754 
2755                 case 0x1F80:
2756                     target[limit++] = 0x1F00;
2757                     target[limit++] = 0x03B9;
2758                     break;
2759 
2760                 case 0x1F81:
2761                     target[limit++] = 0x1F01;
2762                     target[limit++] = 0x03B9;
2763                     break;
2764 
2765                 case 0x1F82:
2766                     target[limit++] = 0x1F02;
2767                     target[limit++] = 0x03B9;
2768                     break;
2769 
2770                 case 0x1F83:
2771                     target[limit++] = 0x1F03;
2772                     target[limit++] = 0x03B9;
2773                     break;
2774 
2775                 case 0x1F84:
2776                     target[limit++] = 0x1F04;
2777                     target[limit++] = 0x03B9;
2778                     break;
2779 
2780                 case 0x1F85:
2781                     target[limit++] = 0x1F05;
2782                     target[limit++] = 0x03B9;
2783                     break;
2784 
2785                 case 0x1F86:
2786                     target[limit++] = 0x1F06;
2787                     target[limit++] = 0x03B9;
2788                     break;
2789 
2790                 case 0x1F87:
2791                     target[limit++] = 0x1F07;
2792                     target[limit++] = 0x03B9;
2793                     break;
2794 
2795                 case 0x1F88:
2796                     target[limit++] = 0x1F00;
2797                     target[limit++] = 0x03B9;
2798                     break;
2799 
2800                 case 0x1F89:
2801                     target[limit++] = 0x1F01;
2802                     target[limit++] = 0x03B9;
2803                     break;
2804 
2805                 case 0x1F8A:
2806                     target[limit++] = 0x1F02;
2807                     target[limit++] = 0x03B9;
2808                     break;
2809 
2810                 case 0x1F8B:
2811                     target[limit++] = 0x1F03;
2812                     target[limit++] = 0x03B9;
2813                     break;
2814 
2815                 case 0x1F8C:
2816                     target[limit++] = 0x1F04;
2817                     target[limit++] = 0x03B9;
2818                     break;
2819 
2820                 case 0x1F8D:
2821                     target[limit++] = 0x1F05;
2822                     target[limit++] = 0x03B9;
2823                     break;
2824 
2825                 case 0x1F8E:
2826                     target[limit++] = 0x1F06;
2827                     target[limit++] = 0x03B9;
2828                     break;
2829 
2830                 case 0x1F8F:
2831                     target[limit++] = 0x1F07;
2832                     target[limit++] = 0x03B9;
2833                     break;
2834 
2835                 case 0x1F90:
2836                     target[limit++] = 0x1F20;
2837                     target[limit++] = 0x03B9;
2838                     break;
2839 
2840                 case 0x1F91:
2841                     target[limit++] = 0x1F21;
2842                     target[limit++] = 0x03B9;
2843                     break;
2844 
2845                 case 0x1F92:
2846                     target[limit++] = 0x1F22;
2847                     target[limit++] = 0x03B9;
2848                     break;
2849 
2850                 case 0x1F93:
2851                     target[limit++] = 0x1F23;
2852                     target[limit++] = 0x03B9;
2853                     break;
2854 
2855                 case 0x1F94:
2856                     target[limit++] = 0x1F24;
2857                     target[limit++] = 0x03B9;
2858                     break;
2859 
2860                 case 0x1F95:
2861                     target[limit++] = 0x1F25;
2862                     target[limit++] = 0x03B9;
2863                     break;
2864 
2865                 case 0x1F96:
2866                     target[limit++] = 0x1F26;
2867                     target[limit++] = 0x03B9;
2868                     break;
2869 
2870                 case 0x1F97:
2871                     target[limit++] = 0x1F27;
2872                     target[limit++] = 0x03B9;
2873                     break;
2874 
2875                 case 0x1F98:
2876                     target[limit++] = 0x1F20;
2877                     target[limit++] = 0x03B9;
2878                     break;
2879 
2880                 case 0x1F99:
2881                     target[limit++] = 0x1F21;
2882                     target[limit++] = 0x03B9;
2883                     break;
2884 
2885                 case 0x1F9A:
2886                     target[limit++] = 0x1F22;
2887                     target[limit++] = 0x03B9;
2888                     break;
2889 
2890                 case 0x1F9B:
2891                     target[limit++] = 0x1F23;
2892                     target[limit++] = 0x03B9;
2893                     break;
2894 
2895                 case 0x1F9C:
2896                     target[limit++] = 0x1F24;
2897                     target[limit++] = 0x03B9;
2898                     break;
2899 
2900                 case 0x1F9D:
2901                     target[limit++] = 0x1F25;
2902                     target[limit++] = 0x03B9;
2903                     break;
2904 
2905                 case 0x1F9E:
2906                     target[limit++] = 0x1F26;
2907                     target[limit++] = 0x03B9;
2908                     break;
2909 
2910                 case 0x1F9F:
2911                     target[limit++] = 0x1F27;
2912                     target[limit++] = 0x03B9;
2913                     break;
2914 
2915                 case 0x1FA0:
2916                     target[limit++] = 0x1F60;
2917                     target[limit++] = 0x03B9;
2918                     break;
2919 
2920                 case 0x1FA1:
2921                     target[limit++] = 0x1F61;
2922                     target[limit++] = 0x03B9;
2923                     break;
2924 
2925                 case 0x1FA2:
2926                     target[limit++] = 0x1F62;
2927                     target[limit++] = 0x03B9;
2928                     break;
2929 
2930                 case 0x1FA3:
2931                     target[limit++] = 0x1F63;
2932                     target[limit++] = 0x03B9;
2933                     break;
2934 
2935                 case 0x1FA4:
2936                     target[limit++] = 0x1F64;
2937                     target[limit++] = 0x03B9;
2938                     break;
2939 
2940                 case 0x1FA5:
2941                     target[limit++] = 0x1F65;
2942                     target[limit++] = 0x03B9;
2943                     break;
2944 
2945                 case 0x1FA6:
2946                     target[limit++] = 0x1F66;
2947                     target[limit++] = 0x03B9;
2948                     break;
2949 
2950                 case 0x1FA7:
2951                     target[limit++] = 0x1F67;
2952                     target[limit++] = 0x03B9;
2953                     break;
2954 
2955                 case 0x1FA8:
2956                     target[limit++] = 0x1F60;
2957                     target[limit++] = 0x03B9;
2958                     break;
2959 
2960                 case 0x1FA9:
2961                     target[limit++] = 0x1F61;
2962                     target[limit++] = 0x03B9;
2963                     break;
2964 
2965                 case 0x1FAA:
2966                     target[limit++] = 0x1F62;
2967                     target[limit++] = 0x03B9;
2968                     break;
2969 
2970                 case 0x1FAB:
2971                     target[limit++] = 0x1F63;
2972                     target[limit++] = 0x03B9;
2973                     break;
2974 
2975                 case 0x1FAC:
2976                     target[limit++] = 0x1F64;
2977                     target[limit++] = 0x03B9;
2978                     break;
2979 
2980                 case 0x1FAD:
2981                     target[limit++] = 0x1F65;
2982                     target[limit++] = 0x03B9;
2983                     break;
2984 
2985                 case 0x1FAE:
2986                     target[limit++] = 0x1F66;
2987                     target[limit++] = 0x03B9;
2988                     break;
2989 
2990                 case 0x1FAF:
2991                     target[limit++] = 0x1F67;
2992                     target[limit++] = 0x03B9;
2993                     break;
2994 
2995                 case 0x1FB2:
2996                     target[limit++] = 0x1F70;
2997                     target[limit++] = 0x03B9;
2998                     break;
2999 
3000                 case 0x1FB3:
3001                     target[limit++] = 0x03B1;
3002                     target[limit++] = 0x03B9;
3003                     break;
3004 
3005                 case 0x1FB4:
3006                     target[limit++] = 0x03AC;
3007                     target[limit++] = 0x03B9;
3008                     break;
3009 
3010                 case 0x1FB6:
3011                     target[limit++] = 0x03B1;
3012                     target[limit++] = 0x0342;
3013                     break;
3014 
3015                 case 0x1FB7:
3016                     target[limit++] = 0x03B1;
3017                     target[limit++] = 0x0342;
3018                     target[limit++] = 0x03B9;
3019                     break;
3020 
3021                 case 0x1FB8:
3022                     target[limit++] = 0x1FB0;
3023                     break;
3024 
3025                 case 0x1FB9:
3026                     target[limit++] = 0x1FB1;
3027                     break;
3028 
3029                 case 0x1FBA:
3030                     target[limit++] = 0x1F70;
3031                     break;
3032 
3033                 case 0x1FBB:
3034                     target[limit++] = 0x1F71;
3035                     break;
3036 
3037                 case 0x1FBC:
3038                     target[limit++] = 0x03B1;
3039                     target[limit++] = 0x03B9;
3040                     break;
3041 
3042                 case 0x1FBE:
3043                     target[limit++] = 0x03B9;
3044                     break;
3045 
3046                 case 0x1FC2:
3047                     target[limit++] = 0x1F74;
3048                     target[limit++] = 0x03B9;
3049                     break;
3050 
3051                 case 0x1FC3:
3052                     target[limit++] = 0x03B7;
3053                     target[limit++] = 0x03B9;
3054                     break;
3055 
3056                 case 0x1FC4:
3057                     target[limit++] = 0x03AE;
3058                     target[limit++] = 0x03B9;
3059                     break;
3060 
3061                 case 0x1FC6:
3062                     target[limit++] = 0x03B7;
3063                     target[limit++] = 0x0342;
3064                     break;
3065 
3066                 case 0x1FC7:
3067                     target[limit++] = 0x03B7;
3068                     target[limit++] = 0x0342;
3069                     target[limit++] = 0x03B9;
3070                     break;
3071 
3072                 case 0x1FC8:
3073                     target[limit++] = 0x1F72;
3074                     break;
3075 
3076                 case 0x1FC9:
3077                     target[limit++] = 0x1F73;
3078                     break;
3079 
3080                 case 0x1FCA:
3081                     target[limit++] = 0x1F74;
3082                     break;
3083 
3084                 case 0x1FCB:
3085                     target[limit++] = 0x1F75;
3086                     break;
3087 
3088                 case 0x1FCC:
3089                     target[limit++] = 0x03B7;
3090                     target[limit++] = 0x03B9;
3091                     break;
3092 
3093                 case 0x1FD2:
3094                     target[limit++] = 0x03B9;
3095                     target[limit++] = 0x0308;
3096                     target[limit++] = 0x0300;
3097                     break;
3098 
3099                 case 0x1FD3:
3100                     target[limit++] = 0x03B9;
3101                     target[limit++] = 0x0308;
3102                     target[limit++] = 0x0301;
3103                     break;
3104 
3105                 case 0x1FD6:
3106                     target[limit++] = 0x03B9;
3107                     target[limit++] = 0x0342;
3108                     break;
3109 
3110                 case 0x1FD7:
3111                     target[limit++] = 0x03B9;
3112                     target[limit++] = 0x0308;
3113                     target[limit++] = 0x0342;
3114                     break;
3115 
3116                 case 0x1FD8:
3117                     target[limit++] = 0x1FD0;
3118                     break;
3119 
3120                 case 0x1FD9:
3121                     target[limit++] = 0x1FD1;
3122                     break;
3123 
3124                 case 0x1FDA:
3125                     target[limit++] = 0x1F76;
3126                     break;
3127 
3128                 case 0x1FDB:
3129                     target[limit++] = 0x1F77;
3130                     break;
3131 
3132                 case 0x1FE2:
3133                     target[limit++] = 0x03C5;
3134                     target[limit++] = 0x0308;
3135                     target[limit++] = 0x0300;
3136                     break;
3137 
3138                 case 0x1FE3:
3139                     target[limit++] = 0x03C5;
3140                     target[limit++] = 0x0308;
3141                     target[limit++] = 0x0301;
3142                     break;
3143 
3144                 case 0x1FE4:
3145                     target[limit++] = 0x03C1;
3146                     target[limit++] = 0x0313;
3147                     break;
3148 
3149                 case 0x1FE6:
3150                     target[limit++] = 0x03C5;
3151                     target[limit++] = 0x0342;
3152                     break;
3153 
3154                 case 0x1FE7:
3155                     target[limit++] = 0x03C5;
3156                     target[limit++] = 0x0308;
3157                     target[limit++] = 0x0342;
3158                     break;
3159 
3160                 case 0x1FE8:
3161                     target[limit++] = 0x1FE0;
3162                     break;
3163 
3164                 case 0x1FE9:
3165                     target[limit++] = 0x1FE1;
3166                     break;
3167 
3168                 case 0x1FEA:
3169                     target[limit++] = 0x1F7A;
3170                     break;
3171 
3172                 case 0x1FEB:
3173                     target[limit++] = 0x1F7B;
3174                     break;
3175 
3176                 case 0x1FEC:
3177                     target[limit++] = 0x1FE5;
3178                     break;
3179 
3180                 case 0x1FF2:
3181                     target[limit++] = 0x1F7C;
3182                     target[limit++] = 0x03B9;
3183                     break;
3184 
3185                 case 0x1FF3:
3186                     target[limit++] = 0x03C9;
3187                     target[limit++] = 0x03B9;
3188                     break;
3189 
3190                 case 0x1FF4:
3191                     target[limit++] = 0x03CE;
3192                     target[limit++] = 0x03B9;
3193                     break;
3194 
3195                 case 0x1FF6:
3196                     target[limit++] = 0x03C9;
3197                     target[limit++] = 0x0342;
3198                     break;
3199 
3200                 case 0x1FF7:
3201                     target[limit++] = 0x03C9;
3202                     target[limit++] = 0x0342;
3203                     target[limit++] = 0x03B9;
3204                     break;
3205 
3206                 case 0x1FF8:
3207                     target[limit++] = 0x1F78;
3208                     break;
3209 
3210                 case 0x1FF9:
3211                     target[limit++] = 0x1F79;
3212                     break;
3213 
3214                 case 0x1FFA:
3215                     target[limit++] = 0x1F7C;
3216                     break;
3217 
3218                 case 0x1FFB:
3219                     target[limit++] = 0x1F7D;
3220                     break;
3221 
3222                 case 0x1FFC:
3223                     target[limit++] = 0x03C9;
3224                     target[limit++] = 0x03B9;
3225                     break;
3226 
3227                 case 0x2000:
3228                 case 0x2001:
3229                 case 0x2002:
3230                 case 0x2003:
3231                 case 0x2004:
3232                 case 0x2005:
3233                 case 0x2006:
3234                 case 0x2007:
3235                 case 0x2008:
3236                 case 0x2009:
3237                 case 0x200A:
3238                     target[limit++] = 0x0020;
3239                     break;
3240 
3241                 case 0x200B:
3242                 case 0x200C:
3243                 case 0x200D:
3244                 case 0x200E:
3245                 case 0x200F:
3246                     break;
3247 
3248                 case 0x2028:
3249                 case 0x2029:
3250                     target[limit++] = 0x0020;
3251                     break;
3252 
3253                 case 0x202A:
3254                 case 0x202B:
3255                 case 0x202C:
3256                 case 0x202D:
3257                 case 0x202E:
3258                     break;
3259 
3260                 case 0x202F:
3261                     target[limit++] = 0x0020;
3262                     break;
3263 
3264                 case 0x205F:
3265                     target[limit++] = 0x0020;
3266                     break;
3267 
3268                 case 0x2060:
3269                 case 0x2061:
3270                 case 0x2062:
3271                 case 0x2063:
3272                     break;
3273 
3274                 case 0x206A:
3275                 case 0x206B:
3276                 case 0x206C:
3277                 case 0x206D:
3278                 case 0x206E:
3279                 case 0x206F:
3280                     break;
3281 
3282                 case 0x20A8:
3283                     target[limit++] = 0x0072;
3284                     target[limit++] = 0x0073;
3285                     break;
3286 
3287                 case 0x2102:
3288                     target[limit++] = 0x0063;
3289                     break;
3290 
3291                 case 0x2103:
3292                     target[limit++] = 0x00B0;
3293                     target[limit++] = 0x0063;
3294                     break;
3295 
3296                 case 0x2107:
3297                     target[limit++] = 0x025B;
3298                     break;
3299 
3300                 case 0x2109:
3301                     target[limit++] = 0x00B0;
3302                     target[limit++] = 0x0066;
3303                     break;
3304 
3305                 case 0x210B:
3306                     target[limit++] = 0x0068;
3307                     break;
3308 
3309                 case 0x210C:
3310                     target[limit++] = 0x0068;
3311                     break;
3312 
3313                 case 0x210D:
3314                     target[limit++] = 0x0068;
3315                     break;
3316 
3317                 case 0x2110:
3318                     target[limit++] = 0x0069;
3319                     break;
3320 
3321                 case 0x2111:
3322                     target[limit++] = 0x0069;
3323                     break;
3324 
3325                 case 0x2112:
3326                     target[limit++] = 0x006C;
3327                     break;
3328 
3329                 case 0x2115:
3330                     target[limit++] = 0x006E;
3331                     break;
3332 
3333                 case 0x2116:
3334                     target[limit++] = 0x006E;
3335                     target[limit++] = 0x006F;
3336                     break;
3337 
3338                 case 0x2119:
3339                     target[limit++] = 0x0070;
3340                     break;
3341 
3342                 case 0x211A:
3343                     target[limit++] = 0x0071;
3344                     break;
3345 
3346                 case 0x211B:
3347                     target[limit++] = 0x0072;
3348                     break;
3349 
3350                 case 0x211C:
3351                     target[limit++] = 0x0072;
3352                     break;
3353 
3354                 case 0x211D:
3355                     target[limit++] = 0x0072;
3356                     break;
3357 
3358                 case 0x2120:
3359                     target[limit++] = 0x0073;
3360                     target[limit++] = 0x006D;
3361                     break;
3362 
3363                 case 0x2121:
3364                     target[limit++] = 0x0074;
3365                     target[limit++] = 0x0065;
3366                     target[limit++] = 0x006C;
3367                     break;
3368 
3369                 case 0x2122:
3370                     target[limit++] = 0x0074;
3371                     target[limit++] = 0x006D;
3372                     break;
3373 
3374                 case 0x2124:
3375                     target[limit++] = 0x007A;
3376                     break;
3377 
3378                 case 0x2126:
3379                     target[limit++] = 0x03C9;
3380                     break;
3381 
3382                 case 0x2128:
3383                     target[limit++] = 0x007A;
3384                     break;
3385 
3386                 case 0x212A:
3387                     target[limit++] = 0x006B;
3388                     break;
3389 
3390                 case 0x212B:
3391                     target[limit++] = 0x00E5;
3392                     break;
3393 
3394                 case 0x212C:
3395                     target[limit++] = 0x0062;
3396                     break;
3397 
3398                 case 0x212D:
3399                     target[limit++] = 0x0063;
3400                     break;
3401 
3402                 case 0x2130:
3403                     target[limit++] = 0x0065;
3404                     break;
3405 
3406                 case 0x2131:
3407                     target[limit++] = 0x0066;
3408                     break;
3409 
3410                 case 0x2133:
3411                     target[limit++] = 0x006D;
3412                     break;
3413 
3414                 case 0x213E:
3415                     target[limit++] = 0x03B3;
3416                     break;
3417 
3418                 case 0x213F:
3419                     target[limit++] = 0x03C0;
3420                     break;
3421 
3422                 case 0x2145:
3423                     target[limit++] = 0x0064;
3424                     break;
3425 
3426                 case 0x2160:
3427                     target[limit++] = 0x2170;
3428                     break;
3429 
3430                 case 0x2161:
3431                     target[limit++] = 0x2171;
3432                     break;
3433 
3434                 case 0x2162:
3435                     target[limit++] = 0x2172;
3436                     break;
3437 
3438                 case 0x2163:
3439                     target[limit++] = 0x2173;
3440                     break;
3441 
3442                 case 0x2164:
3443                     target[limit++] = 0x2174;
3444                     break;
3445 
3446                 case 0x2165:
3447                     target[limit++] = 0x2175;
3448                     break;
3449 
3450                 case 0x2166:
3451                     target[limit++] = 0x2176;
3452                     break;
3453 
3454                 case 0x2167:
3455                     target[limit++] = 0x2177;
3456                     break;
3457 
3458                 case 0x2168:
3459                     target[limit++] = 0x2178;
3460                     break;
3461 
3462                 case 0x2169:
3463                     target[limit++] = 0x2179;
3464                     break;
3465 
3466                 case 0x216A:
3467                     target[limit++] = 0x217A;
3468                     break;
3469 
3470                 case 0x216B:
3471                     target[limit++] = 0x217B;
3472                     break;
3473 
3474                 case 0x216C:
3475                     target[limit++] = 0x217C;
3476                     break;
3477 
3478                 case 0x216D:
3479                     target[limit++] = 0x217D;
3480                     break;
3481 
3482                 case 0x216E:
3483                     target[limit++] = 0x217E;
3484                     break;
3485 
3486                 case 0x216F:
3487                     target[limit++] = 0x217F;
3488                     break;
3489 
3490                 case 0x24B6:
3491                     target[limit++] = 0x24D0;
3492                     break;
3493 
3494                 case 0x24B7:
3495                     target[limit++] = 0x24D1;
3496                     break;
3497 
3498                 case 0x24B8:
3499                     target[limit++] = 0x24D2;
3500                     break;
3501 
3502                 case 0x24B9:
3503                     target[limit++] = 0x24D3;
3504                     break;
3505 
3506                 case 0x24BA:
3507                     target[limit++] = 0x24D4;
3508                     break;
3509 
3510                 case 0x24BB:
3511                     target[limit++] = 0x24D5;
3512                     break;
3513 
3514                 case 0x24BC:
3515                     target[limit++] = 0x24D6;
3516                     break;
3517 
3518                 case 0x24BD:
3519                     target[limit++] = 0x24D7;
3520                     break;
3521 
3522                 case 0x24BE:
3523                     target[limit++] = 0x24D8;
3524                     break;
3525 
3526                 case 0x24BF:
3527                     target[limit++] = 0x24D9;
3528                     break;
3529 
3530                 case 0x24C0:
3531                     target[limit++] = 0x24DA;
3532                     break;
3533 
3534                 case 0x24C1:
3535                     target[limit++] = 0x24DB;
3536                     break;
3537 
3538                 case 0x24C2:
3539                     target[limit++] = 0x24DC;
3540                     break;
3541 
3542                 case 0x24C3:
3543                     target[limit++] = 0x24DD;
3544                     break;
3545 
3546                 case 0x24C4:
3547                     target[limit++] = 0x24DE;
3548                     break;
3549 
3550                 case 0x24C5:
3551                     target[limit++] = 0x24DF;
3552                     break;
3553 
3554                 case 0x24C6:
3555                     target[limit++] = 0x24E0;
3556                     break;
3557 
3558                 case 0x24C7:
3559                     target[limit++] = 0x24E1;
3560                     break;
3561 
3562                 case 0x24C8:
3563                     target[limit++] = 0x24E2;
3564                     break;
3565 
3566                 case 0x24C9:
3567                     target[limit++] = 0x24E3;
3568                     break;
3569 
3570                 case 0x24CA:
3571                     target[limit++] = 0x24E4;
3572                     break;
3573 
3574                 case 0x24CB:
3575                     target[limit++] = 0x24E5;
3576                     break;
3577 
3578                 case 0x24CC:
3579                     target[limit++] = 0x24E6;
3580                     break;
3581 
3582                 case 0x24CD:
3583                     target[limit++] = 0x24E7;
3584                     break;
3585 
3586                 case 0x24CE:
3587                     target[limit++] = 0x24E8;
3588                     break;
3589 
3590                 case 0x24CF:
3591                     target[limit++] = 0x24E9;
3592                     break;
3593 
3594                 case 0x3000:
3595                     target[limit++] = 0x0020;
3596                     break;
3597 
3598                 case 0x3371:
3599                     target[limit++] = 0x0068;
3600                     target[limit++] = 0x0070;
3601                     target[limit++] = 0x0061;
3602                     break;
3603 
3604                 case 0x3373:
3605                     target[limit++] = 0x0061;
3606                     target[limit++] = 0x0075;
3607                     break;
3608 
3609                 case 0x3375:
3610                     target[limit++] = 0x006F;
3611                     target[limit++] = 0x0076;
3612                     break;
3613 
3614                 case 0x3380:
3615                     target[limit++] = 0x0070;
3616                     target[limit++] = 0x0061;
3617                     break;
3618 
3619                 case 0x3381:
3620                     target[limit++] = 0x006E;
3621                     target[limit++] = 0x0061;
3622                     break;
3623 
3624                 case 0x3382:
3625                     target[limit++] = 0x03BC;
3626                     target[limit++] = 0x0061;
3627                     break;
3628 
3629                 case 0x3383:
3630                     target[limit++] = 0x006D;
3631                     target[limit++] = 0x0061;
3632                     break;
3633 
3634                 case 0x3384:
3635                     target[limit++] = 0x006B;
3636                     target[limit++] = 0x0061;
3637                     break;
3638 
3639                 case 0x3385:
3640                     target[limit++] = 0x006B;
3641                     target[limit++] = 0x0062;
3642                     break;
3643 
3644                 case 0x3386:
3645                     target[limit++] = 0x006D;
3646                     target[limit++] = 0x0062;
3647                     break;
3648 
3649                 case 0x3387:
3650                     target[limit++] = 0x0067;
3651                     target[limit++] = 0x0062;
3652                     break;
3653 
3654                 case 0x338A:
3655                     target[limit++] = 0x0070;
3656                     target[limit++] = 0x0066;
3657                     break;
3658 
3659                 case 0x338B:
3660                     target[limit++] = 0x006E;
3661                     target[limit++] = 0x0066;
3662                     break;
3663 
3664                 case 0x338C:
3665                     target[limit++] = 0x03BC;
3666                     target[limit++] = 0x0066;
3667                     break;
3668 
3669                 case 0x3390:
3670                     target[limit++] = 0x0068;
3671                     target[limit++] = 0x007A;
3672                     break;
3673 
3674                 case 0x3391:
3675                     target[limit++] = 0x006B;
3676                     target[limit++] = 0x0068;
3677                     target[limit++] = 0x007A;
3678                     break;
3679 
3680                 case 0x3392:
3681                     target[limit++] = 0x006D;
3682                     target[limit++] = 0x0068;
3683                     target[limit++] = 0x007A;
3684                     break;
3685 
3686                 case 0x3393:
3687                     target[limit++] = 0x0067;
3688                     target[limit++] = 0x0068;
3689                     target[limit++] = 0x007A;
3690                     break;
3691 
3692                 case 0x3394:
3693                     target[limit++] = 0x0074;
3694                     target[limit++] = 0x0068;
3695                     target[limit++] = 0x007A;
3696                     break;
3697 
3698                 case 0x33A9:
3699                     target[limit++] = 0x0070;
3700                     target[limit++] = 0x0061;
3701                     break;
3702 
3703                 case 0x33AA:
3704                     target[limit++] = 0x006B;
3705                     target[limit++] = 0x0070;
3706                     target[limit++] = 0x0061;
3707                     break;
3708 
3709                 case 0x33AB:
3710                     target[limit++] = 0x006D;
3711                     target[limit++] = 0x0070;
3712                     target[limit++] = 0x0061;
3713                     break;
3714 
3715                 case 0x33AC:
3716                     target[limit++] = 0x0067;
3717                     target[limit++] = 0x0070;
3718                     target[limit++] = 0x0061;
3719                     break;
3720 
3721                 case 0x33B4:
3722                     target[limit++] = 0x0070;
3723                     target[limit++] = 0x0076;
3724                     break;
3725 
3726                 case 0x33B5:
3727                     target[limit++] = 0x006E;
3728                     target[limit++] = 0x0076;
3729                     break;
3730 
3731                 case 0x33B6:
3732                     target[limit++] = 0x03BC;
3733                     target[limit++] = 0x0076;
3734                     break;
3735 
3736                 case 0x33B7:
3737                     target[limit++] = 0x006D;
3738                     target[limit++] = 0x0076;
3739                     break;
3740 
3741                 case 0x33B8:
3742                     target[limit++] = 0x006B;
3743                     target[limit++] = 0x0076;
3744                     break;
3745 
3746                 case 0x33B9:
3747                     target[limit++] = 0x006D;
3748                     target[limit++] = 0x0076;
3749                     break;
3750 
3751                 case 0x33BA:
3752                     target[limit++] = 0x0070;
3753                     target[limit++] = 0x0077;
3754                     break;
3755 
3756                 case 0x33BB:
3757                     target[limit++] = 0x006E;
3758                     target[limit++] = 0x0077;
3759                     break;
3760 
3761                 case 0x33BC:
3762                     target[limit++] = 0x03BC;
3763                     target[limit++] = 0x0077;
3764                     break;
3765 
3766                 case 0x33BD:
3767                     target[limit++] = 0x006D;
3768                     target[limit++] = 0x0077;
3769                     break;
3770 
3771                 case 0x33BE:
3772                     target[limit++] = 0x006B;
3773                     target[limit++] = 0x0077;
3774                     break;
3775 
3776                 case 0x33BF:
3777                     target[limit++] = 0x006D;
3778                     target[limit++] = 0x0077;
3779                     break;
3780 
3781                 case 0x33C0:
3782                     target[limit++] = 0x006B;
3783                     target[limit++] = 0x03C9;
3784                     break;
3785 
3786                 case 0x33C1:
3787                     target[limit++] = 0x006D;
3788                     target[limit++] = 0x03C9;
3789                     break;
3790 
3791                 case 0x33C3:
3792                     target[limit++] = 0x0062;
3793                     target[limit++] = 0x0071;
3794                     break;
3795 
3796                 case 0x33C6:
3797                     target[limit++] = 0x0063;
3798                     target[limit++] = 0x2215;
3799                     target[limit++] = 0x006B;
3800                     target[limit++] = 0x0067;
3801                     break;
3802 
3803                 case 0x33C7:
3804                     target[limit++] = 0x0063;
3805                     target[limit++] = 0x006F;
3806                     target[limit++] = 0x002E;
3807                     break;
3808 
3809                 case 0x33C8:
3810                     target[limit++] = 0x0064;
3811                     target[limit++] = 0x0062;
3812                     break;
3813 
3814                 case 0x33C9:
3815                     target[limit++] = 0x0067;
3816                     target[limit++] = 0x0079;
3817                     break;
3818 
3819                 case 0x33CB:
3820                     target[limit++] = 0x0068;
3821                     target[limit++] = 0x0070;
3822                     break;
3823 
3824                 case 0x33CD:
3825                     target[limit++] = 0x006B;
3826                     target[limit++] = 0x006B;
3827                     break;
3828 
3829                 case 0x33CE:
3830                     target[limit++] = 0x006B;
3831                     target[limit++] = 0x006D;
3832                     break;
3833 
3834                 case 0x33D7:
3835                     target[limit++] = 0x0070;
3836                     target[limit++] = 0x0068;
3837                     break;
3838 
3839                 case 0x33D9:
3840                     target[limit++] = 0x0070;
3841                     target[limit++] = 0x0070;
3842                     target[limit++] = 0x006D;
3843                     break;
3844 
3845                 case 0x33DA:
3846                     target[limit++] = 0x0070;
3847                     target[limit++] = 0x0072;
3848                     break;
3849 
3850                 case 0x33DC:
3851                     target[limit++] = 0x0073;
3852                     target[limit++] = 0x0076;
3853                     break;
3854 
3855                 case 0x33DD:
3856                     target[limit++] = 0x0077;
3857                     target[limit++] = 0x0062;
3858                     break;
3859 
3860                 case 0xFB00:
3861                     target[limit++] = 0x0066;
3862                     target[limit++] = 0x0066;
3863                     break;
3864 
3865                 case 0xFB01:
3866                     target[limit++] = 0x0066;
3867                     target[limit++] = 0x0069;
3868                     break;
3869 
3870                 case 0xFB02:
3871                     target[limit++] = 0x0066;
3872                     target[limit++] = 0x006C;
3873                     break;
3874 
3875                 case 0xFB03:
3876                     target[limit++] = 0x0066;
3877                     target[limit++] = 0x0066;
3878                     target[limit++] = 0x0069;
3879                     break;
3880 
3881                 case 0xFB04:
3882                     target[limit++] = 0x0066;
3883                     target[limit++] = 0x0066;
3884                     target[limit++] = 0x006C;
3885                     break;
3886 
3887                 case 0xFB05:
3888                     target[limit++] = 0x0073;
3889                     target[limit++] = 0x0074;
3890                     break;
3891 
3892                 case 0xFB06:
3893                     target[limit++] = 0x0073;
3894                     target[limit++] = 0x0074;
3895                     break;
3896 
3897                 case 0xFB13:
3898                     target[limit++] = 0x0574;
3899                     target[limit++] = 0x0576;
3900                     break;
3901 
3902                 case 0xFB14:
3903                     target[limit++] = 0x0574;
3904                     target[limit++] = 0x0565;
3905                     break;
3906 
3907                 case 0xFB15:
3908                     target[limit++] = 0x0574;
3909                     target[limit++] = 0x056B;
3910                     break;
3911 
3912                 case 0xFB16:
3913                     target[limit++] = 0x057E;
3914                     target[limit++] = 0x0576;
3915                     break;
3916 
3917                 case 0xFB17:
3918                     target[limit++] = 0x0574;
3919                     target[limit++] = 0x056D;
3920                     break;
3921 
3922                 case 0xFE00:
3923                 case 0xFE01:
3924                 case 0xFE02:
3925                 case 0xFE03:
3926                 case 0xFE04:
3927                 case 0xFE05:
3928                 case 0xFE06:
3929                 case 0xFE07:
3930                 case 0xFE08:
3931                 case 0xFE09:
3932                 case 0xFE0A:
3933                 case 0xFE0B:
3934                 case 0xFE0C:
3935                 case 0xFE0D:
3936                 case 0xFE0E:
3937                 case 0xFE0F:
3938                     break;
3939 
3940                 case 0xFEFF:
3941                     break;
3942 
3943                 case 0xFF21:
3944                     target[limit++] = 0xFF41;
3945                     break;
3946 
3947                 case 0xFF22:
3948                     target[limit++] = 0xFF42;
3949                     break;
3950 
3951                 case 0xFF23:
3952                     target[limit++] = 0xFF43;
3953                     break;
3954 
3955                 case 0xFF24:
3956                     target[limit++] = 0xFF44;
3957                     break;
3958 
3959                 case 0xFF25:
3960                     target[limit++] = 0xFF45;
3961                     break;
3962 
3963                 case 0xFF26:
3964                     target[limit++] = 0xFF46;
3965                     break;
3966 
3967                 case 0xFF27:
3968                     target[limit++] = 0xFF47;
3969                     break;
3970 
3971                 case 0xFF28:
3972                     target[limit++] = 0xFF48;
3973                     break;
3974 
3975                 case 0xFF29:
3976                     target[limit++] = 0xFF49;
3977                     break;
3978 
3979                 case 0xFF2A:
3980                     target[limit++] = 0xFF4A;
3981                     break;
3982 
3983                 case 0xFF2B:
3984                     target[limit++] = 0xFF4B;
3985                     break;
3986 
3987                 case 0xFF2C:
3988                     target[limit++] = 0xFF4C;
3989                     break;
3990 
3991                 case 0xFF2D:
3992                     target[limit++] = 0xFF4D;
3993                     break;
3994 
3995                 case 0xFF2E:
3996                     target[limit++] = 0xFF4E;
3997                     break;
3998 
3999                 case 0xFF2F:
4000                     target[limit++] = 0xFF4F;
4001                     break;
4002 
4003                 case 0xFF30:
4004                     target[limit++] = 0xFF50;
4005                     break;
4006 
4007                 case 0xFF31:
4008                     target[limit++] = 0xFF51;
4009                     break;
4010 
4011                 case 0xFF32:
4012                     target[limit++] = 0xFF52;
4013                     break;
4014 
4015                 case 0xFF33:
4016                     target[limit++] = 0xFF53;
4017                     break;
4018 
4019                 case 0xFF34:
4020                     target[limit++] = 0xFF54;
4021                     break;
4022 
4023                 case 0xFF35:
4024                     target[limit++] = 0xFF55;
4025                     break;
4026 
4027                 case 0xFF36:
4028                     target[limit++] = 0xFF56;
4029                     break;
4030 
4031                 case 0xFF37:
4032                     target[limit++] = 0xFF57;
4033                     break;
4034 
4035                 case 0xFF38:
4036                     target[limit++] = 0xFF58;
4037                     break;
4038 
4039                 case 0xFF39:
4040                     target[limit++] = 0xFF59;
4041                     break;
4042 
4043                 case 0xFF3A:
4044                     target[limit++] = 0xFF5A;
4045                     break;
4046 
4047                 case 0xFFF9:
4048                 case 0xFFFA:
4049                 case 0xFFFB:
4050                 case 0xFFFC:
4051                     break;
4052 
4053                 default:
4054                     // First, eliminate surrogates, and replace them by FFFD char
4055                     if ( ( c >= 0xD800 ) && ( c <= 0xDFFF ) )
4056                     {
4057                         target[limit++] = ( char ) 0xFFFD;
4058                         break;
4059                     }
4060 
4061                     target[limit++] = c;
4062                     break;
4063             }
4064         }
4065 
4066         return limit;
4067     }
4068 
4069 
4070     /**
4071      * 
4072      * Prohibit characters described in RFC 4518 :
4073      *  - Table A.1 of RFC 3454
4074      *  - Table C.3 of RFC 3454
4075      *  - Table C.4 of RFC 3454
4076      *  - Table C.5 of RFC 3454
4077      *  - Table C.8 of RFC 3454
4078      *  - character U-FFFD
4079      *
4080      * @param c The char to analyze
4081      * @throws InvalidCharacterException If any character is prohibited
4082      */
4083     private static void checkProhibited( char c ) throws InvalidCharacterException
4084     {
4085         // Shortcut chars above 0x0221
4086         if ( c < 0x221 )
4087         {
4088             return;
4089         }
4090 
4091         // RFC 3454, Table A.1
4092         switch ( c )
4093         {
4094             case 0x0221:
4095             case 0x038B:
4096             case 0x038D:
4097             case 0x03A2:
4098             case 0x03CF:
4099             case 0x0487:
4100             case 0x04CF:
4101             case 0x0560:
4102             case 0x0588:
4103             case 0x05A2:
4104             case 0x05BA:
4105             case 0x0620:
4106             case 0x06FF:
4107             case 0x070E:
4108             case 0x0904:
4109             case 0x0984:
4110             case 0x09A9:
4111             case 0x09B1:
4112             case 0x09BD:
4113             case 0x09DE:
4114             case 0x0A29:
4115             case 0x0A31:
4116             case 0x0A34:
4117             case 0x0A37:
4118             case 0x0A3D:
4119             case 0x0A5D:
4120             case 0x0A84:
4121             case 0x0A8C:
4122             case 0x0A8E:
4123             case 0x0A92:
4124             case 0x0AA9:
4125             case 0x0AB1:
4126             case 0x0AB4:
4127             case 0x0AC6:
4128             case 0x0ACA:
4129             case 0x0B04:
4130             case 0x0B29:
4131             case 0x0B31:
4132             case 0x0B5E:
4133             case 0x0B84:
4134             case 0x0B91:
4135             case 0x0B9B:
4136             case 0x0B9D:
4137             case 0x0BB6:
4138             case 0x0BC9:
4139             case 0x0C04:
4140             case 0x0C0D:
4141             case 0x0C11:
4142             case 0x0C29:
4143             case 0x0C34:
4144             case 0x0C45:
4145             case 0x0C49:
4146             case 0x0C84:
4147             case 0x0C8D:
4148             case 0x0C91:
4149             case 0x0CA9:
4150             case 0x0CB4:
4151             case 0x0CC5:
4152             case 0x0CC9:
4153             case 0x0CDF:
4154             case 0x0D04:
4155             case 0x0D0D:
4156             case 0x0D11:
4157             case 0x0D29:
4158             case 0x0D49:
4159             case 0x0D84:
4160             case 0x0DB2:
4161             case 0x0DBC:
4162             case 0x0DD5:
4163             case 0x0DD7:
4164             case 0x0E83:
4165             case 0x0E89:
4166             case 0x0E98:
4167             case 0x0EA0:
4168             case 0x0EA4:
4169             case 0x0EA6:
4170             case 0x0EAC:
4171             case 0x0EBA:
4172             case 0x0EC5:
4173             case 0x0EC7:
4174             case 0x0F48:
4175             case 0x0F98:
4176             case 0x0FBD:
4177             case 0x1022:
4178             case 0x1028:
4179             case 0x102B:
4180             case 0x1207:
4181             case 0x1247:
4182             case 0x1249:
4183             case 0x1257:
4184             case 0x1259:
4185             case 0x1287:
4186             case 0x1289:
4187             case 0x12AF:
4188             case 0x12B1:
4189             case 0x12BF:
4190             case 0x12C1:
4191             case 0x12CF:
4192             case 0x12D7:
4193             case 0x12EF:
4194             case 0x130F:
4195             case 0x1311:
4196             case 0x131F:
4197             case 0x1347:
4198             case 0x170D:
4199             case 0x176D:
4200             case 0x1771:
4201             case 0x180F:
4202             case 0x1F58:
4203             case 0x1F5A:
4204             case 0x1F5C:
4205             case 0x1F5E:
4206             case 0x1FB5:
4207             case 0x1FC5:
4208             case 0x1FDC:
4209             case 0x1FF5:
4210             case 0x1FFF:
4211             case 0x24FF:
4212             case 0x2618:
4213             case 0x2705:
4214             case 0x2728:
4215             case 0x274C:
4216             case 0x274E:
4217             case 0x2757:
4218             case 0x27B0:
4219             case 0x2E9A:
4220             case 0x3040:
4221             case 0x318F:
4222             case 0x32FF:
4223             case 0x33FF:
4224             case 0xFB37:
4225             case 0xFB3D:
4226             case 0xFB3F:
4227             case 0xFB42:
4228             case 0xFB45:
4229             case 0xFE53:
4230             case 0xFE67:
4231             case 0xFE75:
4232             case 0xFF00:
4233             case 0xFFE7:
4234                 throw new InvalidCharacterException( c );
4235             default:
4236                 break;
4237         }
4238 
4239         // RFC 3454, Table A.1, intervals
4240         if ( ( c >= 0x0234 ) && ( c <= 0x024F ) )
4241         {
4242             throw new InvalidCharacterException( c );
4243         }
4244 
4245         if ( ( c >= 0x02AE ) && ( c <= 0x02AF ) )
4246         {
4247             throw new InvalidCharacterException( c );
4248         }
4249 
4250         if ( ( c >= 0x02EF ) && ( c <= 0x02FF ) )
4251         {
4252             throw new InvalidCharacterException( c );
4253         }
4254 
4255         if ( ( c >= 0x0350 ) && ( c <= 0x035F ) )
4256         {
4257             throw new InvalidCharacterException( c );
4258         }
4259 
4260         if ( ( c >= 0x0370 ) && ( c <= 0x0373 ) )
4261         {
4262             throw new InvalidCharacterException( c );
4263         }
4264 
4265         if ( ( c >= 0x0376 ) && ( c <= 0x0379 ) )
4266         {
4267             throw new InvalidCharacterException( c );
4268         }
4269 
4270         if ( ( c >= 0x037B ) && ( c <= 0x037D ) )
4271         {
4272             throw new InvalidCharacterException( c );
4273         }
4274 
4275         if ( ( c >= 0x037F ) && ( c <= 0x0383 ) )
4276         {
4277             throw new InvalidCharacterException( c );
4278         }
4279 
4280         if ( ( c >= 0x03F7 ) && ( c <= 0x03FF ) )
4281         {
4282             throw new InvalidCharacterException( c );
4283         }
4284 
4285         if ( ( c >= 0x04F6 ) && ( c <= 0x04F7 ) )
4286         {
4287             throw new InvalidCharacterException( c );
4288         }
4289 
4290         if ( ( c >= 0x04FA ) && ( c <= 0x04FF ) )
4291         {
4292             throw new InvalidCharacterException( c );
4293         }
4294 
4295         if ( ( c >= 0x0510 ) && ( c <= 0x0530 ) )
4296         {
4297             throw new InvalidCharacterException( c );
4298         }
4299 
4300         if ( ( c >= 0x0557 ) && ( c <= 0x0558 ) )
4301         {
4302             throw new InvalidCharacterException( c );
4303         }
4304 
4305         if ( ( c >= 0x058B ) && ( c <= 0x0590 ) )
4306         {
4307             throw new InvalidCharacterException( c );
4308         }
4309 
4310         if ( ( c >= 0x05C5 ) && ( c <= 0x05CF ) )
4311         {
4312             throw new InvalidCharacterException( c );
4313         }
4314 
4315         if ( ( c >= 0x05EB ) && ( c <= 0x05EF ) )
4316         {
4317             throw new InvalidCharacterException( c );
4318         }
4319 
4320         if ( ( c >= 0x05F5 ) && ( c <= 0x060B ) )
4321         {
4322             throw new InvalidCharacterException( c );
4323         }
4324 
4325         if ( ( c >= 0x060D ) && ( c <= 0x061A ) )
4326         {
4327             throw new InvalidCharacterException( c );
4328         }
4329 
4330         if ( ( c >= 0x061C ) && ( c <= 0x061E ) )
4331         {
4332             throw new InvalidCharacterException( c );
4333         }
4334 
4335         if ( ( c >= 0x063B ) && ( c <= 0x063F ) )
4336         {
4337             throw new InvalidCharacterException( c );
4338         }
4339 
4340         if ( ( c >= 0x0656 ) && ( c <= 0x065F ) )
4341         {
4342             throw new InvalidCharacterException( c );
4343         }
4344 
4345         if ( ( c >= 0x06EE ) && ( c <= 0x06EF ) )
4346         {
4347             throw new InvalidCharacterException( c );
4348         }
4349 
4350         if ( ( c >= 0x072D ) && ( c <= 0x072F ) )
4351         {
4352             throw new InvalidCharacterException( c );
4353         }
4354 
4355         if ( ( c >= 0x074B ) && ( c <= 0x077F ) )
4356         {
4357             throw new InvalidCharacterException( c );
4358         }
4359 
4360         if ( ( c >= 0x07B2 ) && ( c <= 0x0900 ) )
4361         {
4362             throw new InvalidCharacterException( c );
4363         }
4364 
4365         if ( ( c >= 0x093A ) && ( c <= 0x093B ) )
4366         {
4367             throw new InvalidCharacterException( c );
4368         }
4369 
4370         if ( ( c >= 0x094E ) && ( c <= 0x094F ) )
4371         {
4372             throw new InvalidCharacterException( c );
4373         }
4374 
4375         if ( ( c >= 0x0955 ) && ( c <= 0x0957 ) )
4376         {
4377             throw new InvalidCharacterException( c );
4378         }
4379 
4380         if ( ( c >= 0x0971 ) && ( c <= 0x0980 ) )
4381         {
4382             throw new InvalidCharacterException( c );
4383         }
4384 
4385         if ( ( c >= 0x098D ) && ( c <= 0x098E ) )
4386         {
4387             throw new InvalidCharacterException( c );
4388         }
4389 
4390         if ( ( c >= 0x0991 ) && ( c <= 0x0992 ) )
4391         {
4392             throw new InvalidCharacterException( c );
4393         }
4394 
4395         if ( ( c >= 0x09B3 ) && ( c <= 0x09B5 ) )
4396         {
4397             throw new InvalidCharacterException( c );
4398         }
4399 
4400         if ( ( c >= 0x09BA ) && ( c <= 0x09BB ) )
4401         {
4402             throw new InvalidCharacterException( c );
4403         }
4404 
4405         if ( ( c >= 0x09C5 ) && ( c <= 0x09C6 ) )
4406         {
4407             throw new InvalidCharacterException( c );
4408         }
4409 
4410         if ( ( c >= 0x09C9 ) && ( c <= 0x09CA ) )
4411         {
4412             throw new InvalidCharacterException( c );
4413         }
4414 
4415         if ( ( c >= 0x09CE ) && ( c <= 0x09D6 ) )
4416         {
4417             throw new InvalidCharacterException( c );
4418         }
4419 
4420         if ( ( c >= 0x09D8 ) && ( c <= 0x09DB ) )
4421         {
4422             throw new InvalidCharacterException( c );
4423         }
4424 
4425         if ( ( c >= 0x09E4 ) && ( c <= 0x09E5 ) )
4426         {
4427             throw new InvalidCharacterException( c );
4428         }
4429 
4430         if ( ( c >= 0x09FB ) && ( c <= 0x0A01 ) )
4431         {
4432             throw new InvalidCharacterException( c );
4433         }
4434 
4435         if ( ( c >= 0x0A03 ) && ( c <= 0x0A04 ) )
4436         {
4437             throw new InvalidCharacterException( c );
4438         }
4439 
4440         if ( ( c >= 0x0A0B ) && ( c <= 0x0A0E ) )
4441         {
4442             throw new InvalidCharacterException( c );
4443         }
4444 
4445         if ( ( c >= 0x0A11 ) && ( c <= 0x0A12 ) )
4446         {
4447             throw new InvalidCharacterException( c );
4448         }
4449 
4450         if ( ( c >= 0x0A3A ) && ( c <= 0x0A3B ) )
4451         {
4452             throw new InvalidCharacterException( c );
4453         }
4454 
4455         if ( ( c >= 0x0A43 ) && ( c <= 0x0A46 ) )
4456         {
4457             throw new InvalidCharacterException( c );
4458         }
4459 
4460         if ( ( c >= 0x0A49 ) && ( c <= 0x0A4A ) )
4461         {
4462             throw new InvalidCharacterException( c );
4463         }
4464 
4465         if ( ( c >= 0x0A4E ) && ( c <= 0x0A58 ) )
4466         {
4467             throw new InvalidCharacterException( c );
4468         }
4469 
4470         if ( ( c >= 0x0A5F ) && ( c <= 0x0A65 ) )
4471         {
4472             throw new InvalidCharacterException( c );
4473         }
4474 
4475         if ( ( c >= 0x0A75 ) && ( c <= 0x0A80 ) )
4476         {
4477             throw new InvalidCharacterException( c );
4478         }
4479 
4480         if ( ( c >= 0x0ABA ) && ( c <= 0x0ABB ) )
4481         {
4482             throw new InvalidCharacterException( c );
4483         }
4484 
4485         if ( ( c >= 0x0ACE ) && ( c <= 0x0ACF ) )
4486         {
4487             throw new InvalidCharacterException( c );
4488         }
4489 
4490         if ( ( c >= 0x0AD1 ) && ( c <= 0x0ADF ) )
4491         {
4492             throw new InvalidCharacterException( c );
4493         }
4494 
4495         if ( ( c >= 0x0AE1 ) && ( c <= 0x0AE5 ) )
4496         {
4497             throw new InvalidCharacterException( c );
4498         }
4499 
4500         if ( ( c >= 0x0AF0 ) && ( c <= 0x0B00 ) )
4501         {
4502             throw new InvalidCharacterException( c );
4503         }
4504 
4505         if ( ( c >= 0x0B0D ) && ( c <= 0x0B0E ) )
4506         {
4507             throw new InvalidCharacterException( c );
4508         }
4509 
4510         if ( ( c >= 0x0B11 ) && ( c <= 0x0B12 ) )
4511         {
4512             throw new InvalidCharacterException( c );
4513         }
4514 
4515         if ( ( c >= 0x0B34 ) && ( c <= 0x0B35 ) )
4516         {
4517             throw new InvalidCharacterException( c );
4518         }
4519 
4520         if ( ( c >= 0x0B3A ) && ( c <= 0x0B3B ) )
4521         {
4522             throw new InvalidCharacterException( c );
4523         }
4524 
4525         if ( ( c >= 0x0B44 ) && ( c <= 0x0B46 ) )
4526         {
4527             throw new InvalidCharacterException( c );
4528         }
4529 
4530         if ( ( c >= 0x0B49 ) && ( c <= 0x0B4A ) )
4531         {
4532             throw new InvalidCharacterException( c );
4533         }
4534 
4535         if ( ( c >= 0x0B4E ) && ( c <= 0x0B55 ) )
4536         {
4537             throw new InvalidCharacterException( c );
4538         }
4539 
4540         if ( ( c >= 0x0B58 ) && ( c <= 0x0B5B ) )
4541         {
4542             throw new InvalidCharacterException( c );
4543         }
4544 
4545         if ( ( c >= 0x0B62 ) && ( c <= 0x0B65 ) )
4546         {
4547             throw new InvalidCharacterException( c );
4548         }
4549 
4550         if ( ( c >= 0x0B71 ) && ( c <= 0x0B81 ) )
4551         {
4552             throw new InvalidCharacterException( c );
4553         }
4554 
4555         if ( ( c >= 0x0B8B ) && ( c <= 0x0B8D ) )
4556         {
4557             throw new InvalidCharacterException( c );
4558         }
4559 
4560         if ( ( c >= 0x0B96 ) && ( c <= 0x0B98 ) )
4561         {
4562             throw new InvalidCharacterException( c );
4563         }
4564 
4565         if ( ( c >= 0x0BA0 ) && ( c <= 0x0BA2 ) )
4566         {
4567             throw new InvalidCharacterException( c );
4568         }
4569 
4570         if ( ( c >= 0x0BA5 ) && ( c <= 0x0BA7 ) )
4571         {
4572             throw new InvalidCharacterException( c );
4573         }
4574 
4575         if ( ( c >= 0x0BAB ) && ( c <= 0x0BAD ) )
4576         {
4577             throw new InvalidCharacterException( c );
4578         }
4579 
4580         if ( ( c >= 0x0BBA ) && ( c <= 0x0BBD ) )
4581         {
4582             throw new InvalidCharacterException( c );
4583         }
4584 
4585         if ( ( c >= 0x0BC3 ) && ( c <= 0x0BC5 ) )
4586         {
4587             throw new InvalidCharacterException( c );
4588         }
4589 
4590         if ( ( c >= 0x0BCE ) && ( c <= 0x0BD6 ) )
4591         {
4592             throw new InvalidCharacterException( c );
4593         }
4594 
4595         if ( ( c >= 0x0BD8 ) && ( c <= 0x0BE6 ) )
4596         {
4597             throw new InvalidCharacterException( c );
4598         }
4599 
4600         if ( ( c >= 0x0BF3 ) && ( c <= 0x0C00 ) )
4601         {
4602             throw new InvalidCharacterException( c );
4603         }
4604 
4605         // RFC 3454, Table C.3
4606         if ( ( c >= 0xE000 ) && ( c <= 0xF8FF ) )
4607         {
4608             throw new InvalidCharacterException( c );
4609         }
4610 
4611         // RFC 3454, Table C.4
4612         if ( ( c >= 0xFDD0 ) && ( c <= 0xFDEF ) )
4613         {
4614             throw new InvalidCharacterException( c );
4615         }
4616 
4617         if ( ( c == 0xFFFE ) || ( c == 0xFFFF ) )
4618         {
4619             throw new InvalidCharacterException( c );
4620         }
4621 
4622         // RFC 3454, Table C.5 (Surrogates)
4623         if ( ( c >= 0xD800 ) && ( c <= 0xDFFF ) )
4624         {
4625             throw new InvalidCharacterException( c );
4626         }
4627 
4628         // RFC 3454, Table C.8 
4629         switch ( c )
4630         {
4631             case 0x0340: // COMBINING GRAVE TONE MARK
4632             case 0x0341: // COMBINING ACUTE TONE MARK
4633             case 0x200E: // LEFT-TO-RIGHT MARK
4634             case 0x200F: // RIGHT-TO-LEFT MARK
4635             case 0x202A: // LEFT-TO-RIGHT EMBEDDING
4636             case 0x202B: // RIGHT-TO-LEFT EMBEDDING
4637             case 0x202C: // POP DIRECTIONAL FORMATTING
4638             case 0x202D: // LEFT-TO-RIGHT OVERRIDE
4639             case 0x202E: // RIGHT-TO-LEFT OVERRIDE
4640             case 0x206A: // INHIBIT SYMMETRIC SWAPPING
4641             case 0x206B: // ACTIVATE SYMMETRIC SWAPPING
4642             case 0x206C: // INHIBIT ARABIC FORM SHAPING
4643             case 0x206D: // ACTIVATE ARABIC FORM SHAPING
4644             case 0x206E: // NATIONAL DIGIT SHAPES
4645             case 0x206F: // NOMINAL DIGIT SHAPES
4646                 throw new InvalidCharacterException( c );
4647             default:
4648                 break;
4649         }
4650 
4651         if ( c == 0xFFFD )
4652         {
4653             throw new InvalidCharacterException( c );
4654         }
4655     }
4656 
4657 
4658     /**
4659      * 
4660      * Remove all bidirectionnal chars. This is not really clear in RFC 4518
4661      * what we should do with bidi chars :
4662      * "Bidirectional characters are ignored."
4663      * 
4664      * But it's not explained what is a bidi chars...
4665      * 
4666      * So this method just do nothing atm.
4667      *
4668      * @param str The string where bidi chars are to be removed
4669      * @return The cleaned string
4670      */
4671     public static String bidi( String str )
4672     {
4673         return str;
4674     }
4675 
4676 
4677     /**
4678      * 
4679      * Remove all bidirectionnal chars. This is not really clear in RFC 4518
4680      * what we should do with bidi chars :
4681      * "Bidirectional characters are ignored."
4682      * 
4683      * But it's not explained what is a bidi chars...
4684      * 
4685      * So this method just do nothing atm.
4686      *
4687      * @param array The char array where bidi chars are to be removed
4688      * @return The cleaned StringBuilder
4689      */
4690     public static StringBuilder bidi( char[] array )
4691     {
4692         StringBuilder sb = new StringBuilder( array == null ? 0 : array.length );
4693 
4694         if ( array != null )
4695         {
4696             sb.append( array );
4697         }
4698 
4699         return sb;
4700     }
4701 
4702 
4703     /**
4704      * 
4705      * Remove all insignifiant chars in a Telephone Number :
4706      * Hyphen and spaces. 
4707      * 
4708      * For instance, the following telephone number :
4709      * "+ (33) 1-123--456  789"
4710      * will be trasnformed to :
4711      * "+(33)1123456789"
4712      *
4713      * @param str The telephone number
4714      * @return The modified telephone number String
4715      */
4716     private static String insignifiantCharTelephoneNumber( String str )
4717     {
4718         if ( Strings.isEmpty( str ) )
4719         {
4720             return "";
4721         }
4722 
4723         char[] array = str.toCharArray();
4724 
4725         boolean isSpaceOrHyphen = false;
4726         char soh = '\0';
4727         int pos = 0;
4728 
4729         for ( char c : array )
4730         {
4731             switch ( c )
4732             {
4733                 case 0x0020: // SPACE
4734                 case 0x002D: // HYPHEN-MINUS
4735                 case 0x058A: // ARMENIAN HYPHEN
4736                 case 0x2010: // HYPHEN
4737                 case 0x2011: // NON-BREAKING HYPHEN
4738                 case 0x2212: // MINUS SIGN
4739                 case 0xFE63: // SMALL HYPHEN-MINUS
4740                 case 0xFF0D: // FULLWIDTH HYPHEN-MINUS
4741                     soh = c;
4742                     break;
4743 
4744                 default:
4745                     if ( isSpaceOrHyphen && isCombiningMark( c ) )
4746                     {
4747                         array[pos++] = soh;
4748                         isSpaceOrHyphen = false;
4749                     }
4750 
4751                     array[pos++] = c;
4752                     break;
4753             }
4754         }
4755 
4756         return new String( array, 0, pos );
4757     }
4758 
4759 
4760     /**
4761      * 
4762      * Remove all insignifiant spaces in a numeric string. For
4763      * instance, the following numeric string :
4764      * "  123  456  789  "
4765      * will be transformed to :
4766      * "123456789"
4767      *
4768      * @param str The numeric String
4769      * @return The modified numeric StringBuilder
4770      */
4771     private static String insignifiantCharNumericString( String str )
4772     {
4773         if ( Strings.isEmpty( str ) )
4774         {
4775             return "";
4776         }
4777 
4778         char[] array = str.toCharArray();
4779 
4780         boolean isSpace = false;
4781         int pos = 0;
4782 
4783         for ( char c : array )
4784         {
4785             if ( c != 0x20 )
4786             {
4787                 if ( isSpace && isCombiningMark( c ) )
4788                 {
4789                     array[pos++] = ' ';
4790                     isSpace = false;
4791                 }
4792 
4793                 array[pos++] = c;
4794             }
4795             else
4796             {
4797                 isSpace = true;
4798             }
4799         }
4800 
4801         return new String( array, 0, pos );
4802     }
4803 
4804 
4805     /**
4806      * 
4807      * Remove all insignificant spaces in a string.
4808      * 
4809      * This method use a finite state machine to parse
4810      * the text.
4811      * 
4812      * @param str The String to modify
4813      * @param caseSensitive A flag telling if the chars must be lower cased
4814      * @return The modified StringBuilder
4815      * @throws InvalidCharacterException If an invalid character is found in the String
4816      */
4817     private static String insignifiantSpacesString( String str, boolean caseSensitive )
4818         throws InvalidCharacterException
4819     {
4820         if ( Strings.isEmpty( str ) )
4821         {
4822             // Special case : an empty strings is replaced by 2 spaces
4823             return "";
4824         }
4825 
4826         char[] array = str.toCharArray();
4827 
4828         // Create a target char array which is 3 times bigger than the original size. 
4829         // We have to do that because the map phase may transform a char to
4830         // three chars.
4831         // TODO : we have to find a way to prevent this waste of space.
4832         char[] target = new char[str.length() * 3 + 2];
4833 
4834         int pos = 0;
4835         char lowerCase = ( char ) ( caseSensitive ? 0x00 : 0x20 );
4836 
4837         // First pass to map the chars
4838         //System.arraycopy( array, 0, target, 0, array.length );
4839         int limit = map( array, target, lowerCase );
4840         pos = 0;
4841 
4842         // Second pass to remove spaces. We work on the target
4843         int i = 0;
4844         char c = '\0';
4845 
4846         // First remove starting spaces
4847         for ( i = 0; i < limit; i++ )
4848         {
4849             c = target[i];
4850 
4851             if ( c != ' ' )
4852             {
4853                 checkProhibited( c );
4854                 break;
4855             }
4856         }
4857 
4858         // Now, 'i' will be the starting point. We will just handle the special
4859         // case of a combining character
4860         int start = i;
4861 
4862         if ( start == limit )
4863         {
4864             // we only have spaces, we keep only one
4865             return " ";
4866         }
4867         else if ( isCombiningMark( c ) )
4868         {
4869             if ( start == 0 )
4870             {
4871                 // The first char can't be a combining char
4872                 throw new InvalidCharacterException( c );
4873             }
4874             else
4875             {
4876                 target[pos++] = ' ';
4877                 target[pos++] = c;
4878                 start++;
4879             }
4880         }
4881         else
4882         {
4883             target[pos++] = c;
4884             start++;
4885         }
4886 
4887         // Now remove the spaces at the end
4888         for ( i = limit - 1; i > start; i-- )
4889         {
4890             if ( target[i] != ' ' )
4891             {
4892                 break;
4893             }
4894         }
4895 
4896         limit = i + 1;
4897 
4898         // Let's deal with the following chars. It will be
4899         // a list of chars and spaces. We will consider that
4900         // we have couples of chars and spaces :
4901         // (char * space*)*. We have a special case :
4902         // a space followed by a combining char.
4903         boolean spaceSeen = false;
4904         boolean space2Seen = false;
4905 
4906         for ( i = start; i < limit; i++ )
4907         {
4908             c = target[i];
4909 
4910             checkProhibited( c );
4911 
4912             if ( isCombiningMark( c ) )
4913             {
4914                 if ( spaceSeen )
4915                 {
4916                     if ( space2Seen )
4917                     {
4918                         target[pos++] = ' ';
4919                     }
4920 
4921                     target[pos++] = ' ';
4922                     target[pos++] = c;
4923                     spaceSeen = false;
4924                     space2Seen = false;
4925                 }
4926                 else
4927                 {
4928                     target[pos++] = c;
4929                 }
4930             }
4931             else if ( c == ' ' )
4932             {
4933                 if ( spaceSeen )
4934                 {
4935                     space2Seen = true;
4936                 }
4937                 else
4938                 {
4939                     spaceSeen = true;
4940                 }
4941             }
4942             else
4943             {
4944                 if ( spaceSeen )
4945                 {
4946                     target[pos++] = ' ';
4947                     spaceSeen = false;
4948                     space2Seen = false;
4949                 }
4950 
4951                 target[pos++] = c;
4952             }
4953         }
4954 
4955         return new String( target, 0, pos );
4956     }
4957 
4958 
4959     /**
4960      * Remove all insignificant spaces in a Ascii string.
4961      * 
4962      * This method use a finite state machine to parse
4963      * the text.
4964      * 
4965      * @param str The String to modify
4966      * @param caseSensitive A flag telling if the chars must be lower cased
4967      * @return The modified StringBuilder
4968      * @throws InvalidCharacterException If an invalid character is found in the String
4969      */
4970     private static String insignifiantSpacesStringAscii( String str, boolean caseSensitive )
4971         throws InvalidCharacterException
4972     {
4973         if ( Strings.isEmpty( str ) )
4974         {
4975             // Special case : an empty strings is replaced by 2 spaces
4976             return "";
4977         }
4978 
4979         char[] array = str.toCharArray();
4980 
4981         int pos = 0;
4982         char lowerCase = ( char ) ( caseSensitive ? 0x00 : 0x20 );
4983 
4984         // First pass to map the chars
4985         int limit = map( array, array, lowerCase );
4986         pos = 0;
4987 
4988         // Second pass to remove spaces. We work on the target
4989         int i = 0;
4990         char c = '\0';
4991 
4992         // First remove starting spaces
4993         for ( i = 0; i < limit; i++ )
4994         {
4995             c = array[i];
4996 
4997             if ( c != ' ' )
4998             {
4999                 checkProhibited( c );
5000                 break;
5001             }
5002         }
5003 
5004         // Now, 'i' will be the starting point. We will just handle the special
5005         // case of a combining character
5006         int start = i;
5007 
5008         if ( start == limit )
5009         {
5010             // we only have spaces, we keep only one
5011             return " ";
5012         }
5013         else if ( isCombiningMark( c ) )
5014         {
5015             if ( start == 0 )
5016             {
5017                 // The first char can't be a combining char
5018                 throw new InvalidCharacterException( c );
5019             }
5020             else
5021             {
5022                 throw new InvalidCharacterException( c );
5023             }
5024         }
5025         else
5026         {
5027             array[pos++] = c;
5028             start++;
5029         }
5030 
5031         // Now remove the spaces at the end
5032         for ( i = limit - 1; i > start; i-- )
5033         {
5034             if ( array[i] != ' ' )
5035             {
5036                 break;
5037             }
5038         }
5039 
5040         limit = i + 1;
5041 
5042         // Let's deal with the following chars. It will be
5043         // a list of chars and spaces. We will consider that
5044         // we have couples of chars and spaces :
5045         // (char* space*)*. We have a special case :
5046         // a space followed by a combining char.
5047         boolean spaceSeen = false;
5048 
5049         for ( i = start; i < limit; i++ )
5050         {
5051             c = array[i];
5052 
5053             checkProhibited( c );
5054 
5055             if ( isCombiningMark( c ) )
5056             {
5057                 throw new InvalidCharacterException( c );
5058             }
5059             else if ( c == ' ' )
5060             {
5061                 spaceSeen = true;
5062             }
5063             else
5064             {
5065                 if ( spaceSeen )
5066                 {
5067                     array[pos++] = ' ';
5068                     spaceSeen = false;
5069                 }
5070 
5071                 array[pos++] = c;
5072             }
5073         }
5074 
5075         return new String( array, 0, pos );
5076     }
5077 }