* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / corlib / Mono.Globalization.Unicode / NormalizationTableUtil.cs
1 using System;
2 using System.Globalization;
3 using System.Text;
4
5 namespace Mono.Globalization.Unicode
6 {
7         internal class NormalizationTableUtil
8         {
9                 public static readonly CodePointIndexer Prop;
10                 public static readonly CodePointIndexer Map;
11                 public static readonly CodePointIndexer Combining;
12                 public static readonly CodePointIndexer Composite;
13                 public static readonly CodePointIndexer Helper;
14
15                 static NormalizationTableUtil ()
16                 {
17                         int [] propStarts = new int [] {
18                                 0, 0x0910, 0x1D00, 0x2460, 0x2980,
19                                 0x2D60, 0x2E90, 0xF900,
20 //                              0x1D100, 0x2f800, 0x2fa10
21                                 };
22                         int [] propEnds = new int [] {
23                                 0x06E0, 0x1200, 0x2330, 0x2600, 0x2AE0,
24                                 0x2D70, 0x3400, 0x10000,
25 //                              0x1D800, 0x2f810, 0x2fa20
26                                 };
27                         int [] mapStarts = new int [] {
28                                 0x90, 0x0920, 0x1D20, 0x2460, 0x24A0, 0x2A00,
29                                 0x2D60, 0x2E90, 0xF900,
30 //                              0x1d150, 0x2f800
31                                 };
32                         int [] mapEnds = new int [] {
33                                 0x06E0, 0x1100, 0x2330, 0x24A0, 0x24F0, 0x2AE0,
34                                 0x2D70, 0x3400, 0x10000,
35 //                              0x1d800, 0x2fb00
36                                 };
37                         int [] combiningStarts = new int [] {
38                                 0x02F0, 0x0480, 0x0590, 0x0930, 0x09B0,
39                                 0x0A30, 0x0AB0, 0x0B30, 0x0BC0, 0x0C40,
40                                 0x0CB0, 0x0D40, 0x0DC0, 0x0E30, 0x0EB0,
41                                 0x0F00, 0x1030, 0x1350, 0x1710, 0x17D0,
42                                 0x18A0, 0x1930, 0x1A10, 0x1DC0, 0x20D0,
43                                 0x3020, 0x3090, 0xA800, 0xFB10, 0xFE20,
44 //                              0x10A00, 0x1D160, 0x1D240
45                                 };
46                         int [] combiningEnds = new int [] {
47                                 0x0360, 0x0490, 0x0750, 0x0960, 0x09D0,
48                                 0x0A50, 0x0AD0, 0x0B50, 0x0BD0, 0x0C60,
49                                 0x0CD0, 0x0D50, 0x0DD0, 0x0E50, 0x0ED0,
50                                 0x0FD0, 0x1040, 0x1360, 0x1740, 0x17E0,
51                                 0x18B0, 0x1940, 0x1A20, 0x1DD0, 0x20F0,
52                                 0x3030, 0x30A0, 0xA810, 0xFB20, 0xFE30,
53 //                              0x10A40, 0x1D1B0, 0x1D250
54                                 };
55                         // since mapToCompositeIndex only holds canonical
56                         // mappings, those indexes could be still shorten.
57                         int [] compositeStarts = new int [] {
58                                 0x480, 0x1450, 0x16D0
59                                 };
60                         int [] compositeEnds = new int [] {
61                                 0x10C0, 0x15D0, 0x2190
62                                 };
63                         int [] helperStarts = new int [] {
64                                 0, 0x900, 0x1D00, 0x2500, 0x3000, 0x3B90,
65                                 0x4010, 0x4E00, 0xFB40,
66 //                              0x1D150, 0x20100, 0x20510,
67 //                              0x20630, 0x20800, 0x20A20, 0x20B60, 0x214E0,
68                                 };
69                         int [] helperEnds = new int [] {
70                                 0x700, 0x1200, 0x2300, 0x2600, 0x3160, 0x3BA0, 
71                                 0x4030, 0xA000, 0xFB50,
72 //                              0x1D1C0, 0x20130, 0x20550,
73 //                              0x20640, 0x208E0, 0x20A30, 0x20B70, 0x214F0,
74                                 };
75
76                         Prop = new CodePointIndexer (propStarts, propEnds, 0, 0);
77                         Map = new CodePointIndexer (mapStarts, mapEnds, 0, 0);
78                         Combining = new CodePointIndexer (combiningStarts,
79                                 combiningEnds, 0, 0);
80                         Composite = new CodePointIndexer (compositeStarts,
81                                 compositeEnds, 0, 0);
82                         Helper = new CodePointIndexer (helperStarts, helperEnds,
83                                 0, 0);
84                 }
85
86                 public static int PropIdx (int cp)
87                 {
88                         return Prop.ToIndex (cp);
89                 }
90
91                 public static int PropCP (int index)
92                 {
93                         return Prop.ToCodePoint (index);
94                 }
95
96                 public static int PropCount { get { return Prop.TotalCount; } }
97
98                 public static int MapIdx (int cp)
99                 {
100                         return Map.ToIndex (cp);
101                 }
102
103                 public static int MapCP (int index)
104                 {
105                         return Map.ToCodePoint (index);
106                 }
107
108                 public static int CbIdx (int cp)
109                 {
110                         return Combining.ToIndex (cp);
111                 }
112
113                 public static int CbCP (int index)
114                 {
115                         return Combining.ToCodePoint (index);
116                 }
117
118                 public static int MapCount { get { return Map.TotalCount; } }
119         }
120 }