1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Peter Bartok (pbartok@novell.com)
29 using System.Collections;
31 namespace System.Windows.Forms.RTF {
32 internal class Charcode {
33 #region Local Variables
34 private StandardCharCode[] codes;
35 private Hashtable reverse;
37 #endregion // Local Variables
40 static Charcode ansi_generic;
43 #region Public Constructors
44 public Charcode() : this(256) {
47 private Charcode(int size) {
49 this.codes = new StandardCharCode[size];
50 this.reverse = new Hashtable(size);
52 // No need to reinitialize array to its default value
53 //for (int i = 0; i < size; i++) {
54 // codes[i] = StandardCharCode.nothing;
57 #endregion // Public Constructors
59 #region Public Instance Properties
60 public int this[StandardCharCode c] {
68 for (int i = 0; i < size; i++) {
78 public StandardCharCode this[int c] {
80 if (c < 0 || c >= size) {
81 return StandardCharCode.nothing;
88 if (c < 0 || c >= size) {
96 #endregion // Public Instance Properties
98 #region Public Instance Methods
99 #endregion // Public Instance Methods
101 #region Public Static Methods
102 public static Charcode AnsiGeneric {
104 if (ansi_generic != null)
107 ansi_generic = new Charcode(256);
109 ansi_generic[0x06] = StandardCharCode.formula;
110 ansi_generic[0x1e] = StandardCharCode.nobrkhyphen;
111 ansi_generic[0x1f] = StandardCharCode.opthyphen;
112 ansi_generic[' '] = StandardCharCode.space;
113 ansi_generic['!'] = StandardCharCode.exclam;
114 ansi_generic['"'] = StandardCharCode.quotedbl;
115 ansi_generic['#'] = StandardCharCode.numbersign;
116 ansi_generic['$'] = StandardCharCode.dollar;
117 ansi_generic['%'] = StandardCharCode.percent;
118 ansi_generic['&'] = StandardCharCode.ampersand;
119 ansi_generic['\\'] = StandardCharCode.quoteright;
120 ansi_generic['('] = StandardCharCode.parenleft;
121 ansi_generic[')'] = StandardCharCode.parenright;
122 ansi_generic['*'] = StandardCharCode.asterisk;
123 ansi_generic['+'] = StandardCharCode.plus;
124 ansi_generic[','] = StandardCharCode.comma;
125 ansi_generic['-'] = StandardCharCode.hyphen;
126 ansi_generic['.'] = StandardCharCode.period;
127 ansi_generic['/'] = StandardCharCode.slash;
128 ansi_generic['0'] = StandardCharCode.zero;
129 ansi_generic['1'] = StandardCharCode.one;
130 ansi_generic['2'] = StandardCharCode.two;
131 ansi_generic['3'] = StandardCharCode.three;
132 ansi_generic['4'] = StandardCharCode.four;
133 ansi_generic['5'] = StandardCharCode.five;
134 ansi_generic['6'] = StandardCharCode.six;
135 ansi_generic['7'] = StandardCharCode.seven;
136 ansi_generic['8'] = StandardCharCode.eight;
137 ansi_generic['9'] = StandardCharCode.nine;
138 ansi_generic[':'] = StandardCharCode.colon;
139 ansi_generic[';'] = StandardCharCode.semicolon;
140 ansi_generic['<'] = StandardCharCode.less;
141 ansi_generic['='] = StandardCharCode.equal;
142 ansi_generic['>'] = StandardCharCode.greater;
143 ansi_generic['?'] = StandardCharCode.question;
144 ansi_generic['@'] = StandardCharCode.at;
145 ansi_generic['A'] = StandardCharCode.A;
146 ansi_generic['B'] = StandardCharCode.B;
147 ansi_generic['C'] = StandardCharCode.C;
148 ansi_generic['D'] = StandardCharCode.D;
149 ansi_generic['E'] = StandardCharCode.E;
150 ansi_generic['F'] = StandardCharCode.F;
151 ansi_generic['G'] = StandardCharCode.G;
152 ansi_generic['H'] = StandardCharCode.H;
153 ansi_generic['I'] = StandardCharCode.I;
154 ansi_generic['J'] = StandardCharCode.J;
155 ansi_generic['K'] = StandardCharCode.K;
156 ansi_generic['L'] = StandardCharCode.L;
157 ansi_generic['M'] = StandardCharCode.M;
158 ansi_generic['N'] = StandardCharCode.N;
159 ansi_generic['O'] = StandardCharCode.O;
160 ansi_generic['P'] = StandardCharCode.P;
161 ansi_generic['Q'] = StandardCharCode.Q;
162 ansi_generic['R'] = StandardCharCode.R;
163 ansi_generic['S'] = StandardCharCode.S;
164 ansi_generic['T'] = StandardCharCode.T;
165 ansi_generic['U'] = StandardCharCode.U;
166 ansi_generic['V'] = StandardCharCode.V;
167 ansi_generic['W'] = StandardCharCode.W;
168 ansi_generic['X'] = StandardCharCode.X;
169 ansi_generic['Y'] = StandardCharCode.Y;
170 ansi_generic['Z'] = StandardCharCode.Z;
171 ansi_generic['['] = StandardCharCode.bracketleft;
172 ansi_generic['\\'] = StandardCharCode.backslash;
173 ansi_generic[']'] = StandardCharCode.bracketright;
174 ansi_generic['^'] = StandardCharCode.asciicircum;
175 ansi_generic['_'] = StandardCharCode.underscore;
176 ansi_generic['`'] = StandardCharCode.quoteleft;
177 ansi_generic['a'] = StandardCharCode.a;
178 ansi_generic['b'] = StandardCharCode.b;
179 ansi_generic['c'] = StandardCharCode.c;
180 ansi_generic['d'] = StandardCharCode.d;
181 ansi_generic['e'] = StandardCharCode.e;
182 ansi_generic['f'] = StandardCharCode.f;
183 ansi_generic['g'] = StandardCharCode.g;
184 ansi_generic['h'] = StandardCharCode.h;
185 ansi_generic['i'] = StandardCharCode.i;
186 ansi_generic['j'] = StandardCharCode.j;
187 ansi_generic['k'] = StandardCharCode.k;
188 ansi_generic['l'] = StandardCharCode.l;
189 ansi_generic['m'] = StandardCharCode.m;
190 ansi_generic['n'] = StandardCharCode.n;
191 ansi_generic['o'] = StandardCharCode.o;
192 ansi_generic['p'] = StandardCharCode.p;
193 ansi_generic['q'] = StandardCharCode.q;
194 ansi_generic['r'] = StandardCharCode.r;
195 ansi_generic['s'] = StandardCharCode.s;
196 ansi_generic['t'] = StandardCharCode.t;
197 ansi_generic['u'] = StandardCharCode.u;
198 ansi_generic['v'] = StandardCharCode.v;
199 ansi_generic['w'] = StandardCharCode.w;
200 ansi_generic['x'] = StandardCharCode.x;
201 ansi_generic['y'] = StandardCharCode.y;
202 ansi_generic['z'] = StandardCharCode.z;
203 ansi_generic['{'] = StandardCharCode.braceleft;
204 ansi_generic['|'] = StandardCharCode.bar;
205 ansi_generic['}'] = StandardCharCode.braceright;
206 ansi_generic['~'] = StandardCharCode.asciitilde;
207 ansi_generic[0xa0] = StandardCharCode.nobrkspace;
208 ansi_generic[0xa1] = StandardCharCode.exclamdown;
209 ansi_generic[0xa2] = StandardCharCode.cent;
210 ansi_generic[0xa3] = StandardCharCode.sterling;
211 ansi_generic[0xa4] = StandardCharCode.currency;
212 ansi_generic[0xa5] = StandardCharCode.yen;
213 ansi_generic[0xa6] = StandardCharCode.brokenbar;
214 ansi_generic[0xa7] = StandardCharCode.section;
215 ansi_generic[0xa8] = StandardCharCode.dieresis;
216 ansi_generic[0xa9] = StandardCharCode.copyright;
217 ansi_generic[0xaa] = StandardCharCode.ordfeminine;
218 ansi_generic[0xab] = StandardCharCode.guillemotleft;
219 ansi_generic[0xac] = StandardCharCode.logicalnot;
220 ansi_generic[0xad] = StandardCharCode.opthyphen;
221 ansi_generic[0xae] = StandardCharCode.registered;
222 ansi_generic[0xaf] = StandardCharCode.macron;
223 ansi_generic[0xb0] = StandardCharCode.degree;
224 ansi_generic[0xb1] = StandardCharCode.plusminus;
225 ansi_generic[0xb2] = StandardCharCode.twosuperior;
226 ansi_generic[0xb3] = StandardCharCode.threesuperior;
227 ansi_generic[0xb4] = StandardCharCode.acute;
228 ansi_generic[0xb5] = StandardCharCode.mu;
229 ansi_generic[0xb6] = StandardCharCode.paragraph;
230 ansi_generic[0xb7] = StandardCharCode.periodcentered;
231 ansi_generic[0xb8] = StandardCharCode.cedilla;
232 ansi_generic[0xb9] = StandardCharCode.onesuperior;
233 ansi_generic[0xba] = StandardCharCode.ordmasculine;
234 ansi_generic[0xbb] = StandardCharCode.guillemotright;
235 ansi_generic[0xbc] = StandardCharCode.onequarter;
236 ansi_generic[0xbd] = StandardCharCode.onehalf;
237 ansi_generic[0xbe] = StandardCharCode.threequarters;
238 ansi_generic[0xbf] = StandardCharCode.questiondown;
239 ansi_generic[0xc0] = StandardCharCode.Agrave;
240 ansi_generic[0xc1] = StandardCharCode.Aacute;
241 ansi_generic[0xc2] = StandardCharCode.Acircumflex;
242 ansi_generic[0xc3] = StandardCharCode.Atilde;
243 ansi_generic[0xc4] = StandardCharCode.Adieresis;
244 ansi_generic[0xc5] = StandardCharCode.Aring;
245 ansi_generic[0xc6] = StandardCharCode.AE;
246 ansi_generic[0xc7] = StandardCharCode.Ccedilla;
247 ansi_generic[0xc8] = StandardCharCode.Egrave;
248 ansi_generic[0xc9] = StandardCharCode.Eacute;
249 ansi_generic[0xca] = StandardCharCode.Ecircumflex;
250 ansi_generic[0xcb] = StandardCharCode.Edieresis;
251 ansi_generic[0xcc] = StandardCharCode.Igrave;
252 ansi_generic[0xcd] = StandardCharCode.Iacute;
253 ansi_generic[0xce] = StandardCharCode.Icircumflex;
254 ansi_generic[0xcf] = StandardCharCode.Idieresis;
255 ansi_generic[0xd0] = StandardCharCode.Eth;
256 ansi_generic[0xd1] = StandardCharCode.Ntilde;
257 ansi_generic[0xd2] = StandardCharCode.Ograve;
258 ansi_generic[0xd3] = StandardCharCode.Oacute;
259 ansi_generic[0xd4] = StandardCharCode.Ocircumflex;
260 ansi_generic[0xd5] = StandardCharCode.Otilde;
261 ansi_generic[0xd6] = StandardCharCode.Odieresis;
262 ansi_generic[0xd7] = StandardCharCode.multiply;
263 ansi_generic[0xd8] = StandardCharCode.Oslash;
264 ansi_generic[0xd9] = StandardCharCode.Ugrave;
265 ansi_generic[0xda] = StandardCharCode.Uacute;
266 ansi_generic[0xdb] = StandardCharCode.Ucircumflex;
267 ansi_generic[0xdc] = StandardCharCode.Udieresis;
268 ansi_generic[0xdd] = StandardCharCode.Yacute;
269 ansi_generic[0xde] = StandardCharCode.Thorn;
270 ansi_generic[0xdf] = StandardCharCode.germandbls;
271 ansi_generic[0xe0] = StandardCharCode.agrave;
272 ansi_generic[0xe1] = StandardCharCode.aacute;
273 ansi_generic[0xe2] = StandardCharCode.acircumflex;
274 ansi_generic[0xe3] = StandardCharCode.atilde;
275 ansi_generic[0xe4] = StandardCharCode.adieresis;
276 ansi_generic[0xe5] = StandardCharCode.aring;
277 ansi_generic[0xe6] = StandardCharCode.ae;
278 ansi_generic[0xe7] = StandardCharCode.ccedilla;
279 ansi_generic[0xe8] = StandardCharCode.egrave;
280 ansi_generic[0xe9] = StandardCharCode.eacute;
281 ansi_generic[0xea] = StandardCharCode.ecircumflex;
282 ansi_generic[0xeb] = StandardCharCode.edieresis;
283 ansi_generic[0xec] = StandardCharCode.igrave;
284 ansi_generic[0xed] = StandardCharCode.iacute;
285 ansi_generic[0xee] = StandardCharCode.icircumflex;
286 ansi_generic[0xef] = StandardCharCode.idieresis;
287 ansi_generic[0xf0] = StandardCharCode.eth;
288 ansi_generic[0xf1] = StandardCharCode.ntilde;
289 ansi_generic[0xf2] = StandardCharCode.ograve;
290 ansi_generic[0xf3] = StandardCharCode.oacute;
291 ansi_generic[0xf4] = StandardCharCode.ocircumflex;
292 ansi_generic[0xf5] = StandardCharCode.otilde;
293 ansi_generic[0xf6] = StandardCharCode.odieresis;
294 ansi_generic[0xf7] = StandardCharCode.divide;
295 ansi_generic[0xf8] = StandardCharCode.oslash;
296 ansi_generic[0xf9] = StandardCharCode.ugrave;
297 ansi_generic[0xfa] = StandardCharCode.uacute;
298 ansi_generic[0xfb] = StandardCharCode.ucircumflex;
299 ansi_generic[0xfc] = StandardCharCode.udieresis;
300 ansi_generic[0xfd] = StandardCharCode.yacute;
301 ansi_generic[0xfe] = StandardCharCode.thorn;
302 ansi_generic[0xff] = StandardCharCode.ydieresis;
308 public static Charcode AnsiSymbol {
310 Charcode code = new Charcode(256);
312 code[0x06] = StandardCharCode.formula;
313 code[0x1e] = StandardCharCode.nobrkhyphen;
314 code[0x1f] = StandardCharCode.opthyphen;
315 code[' '] = StandardCharCode.space;
316 code['!'] = StandardCharCode.exclam;
317 code['"'] = StandardCharCode.universal;
318 code['#'] = StandardCharCode.mathnumbersign;
319 code['$'] = StandardCharCode.existential;
320 code['%'] = StandardCharCode.percent;
321 code['&'] = StandardCharCode.ampersand;
322 code['\\'] = StandardCharCode.suchthat;
323 code['('] = StandardCharCode.parenleft;
324 code[')'] = StandardCharCode.parenright;
325 code['*'] = StandardCharCode.mathasterisk;
326 code['+'] = StandardCharCode.mathplus;
327 code[','] = StandardCharCode.comma;
328 code['-'] = StandardCharCode.mathminus;
329 code['.'] = StandardCharCode.period;
330 code['/'] = StandardCharCode.slash;
331 code['0'] = StandardCharCode.zero;
332 code['1'] = StandardCharCode.one;
333 code['2'] = StandardCharCode.two;
334 code['3'] = StandardCharCode.three;
335 code['4'] = StandardCharCode.four;
336 code['5'] = StandardCharCode.five;
337 code['6'] = StandardCharCode.six;
338 code['7'] = StandardCharCode.seven;
339 code['8'] = StandardCharCode.eight;
340 code['9'] = StandardCharCode.nine;
341 code[':'] = StandardCharCode.colon;
342 code[';'] = StandardCharCode.semicolon;
343 code['<'] = StandardCharCode.less;
344 code['='] = StandardCharCode.mathequal;
345 code['>'] = StandardCharCode.greater;
346 code['?'] = StandardCharCode.question;
347 code['@'] = StandardCharCode.congruent;
348 code['A'] = StandardCharCode.Alpha;
349 code['B'] = StandardCharCode.Beta;
350 code['C'] = StandardCharCode.Chi;
351 code['D'] = StandardCharCode.Delta;
352 code['E'] = StandardCharCode.Epsilon;
353 code['F'] = StandardCharCode.Phi;
354 code['G'] = StandardCharCode.Gamma;
355 code['H'] = StandardCharCode.Eta;
356 code['I'] = StandardCharCode.Iota;
357 code['K'] = StandardCharCode.Kappa;
358 code['L'] = StandardCharCode.Lambda;
359 code['M'] = StandardCharCode.Mu;
360 code['N'] = StandardCharCode.Nu;
361 code['O'] = StandardCharCode.Omicron;
362 code['P'] = StandardCharCode.Pi;
363 code['Q'] = StandardCharCode.Theta;
364 code['R'] = StandardCharCode.Rho;
365 code['S'] = StandardCharCode.Sigma;
366 code['T'] = StandardCharCode.Tau;
367 code['U'] = StandardCharCode.Upsilon;
368 code['V'] = StandardCharCode.varsigma;
369 code['W'] = StandardCharCode.Omega;
370 code['X'] = StandardCharCode.Xi;
371 code['Y'] = StandardCharCode.Psi;
372 code['Z'] = StandardCharCode.Zeta;
373 code['['] = StandardCharCode.bracketleft;
374 code['\\'] = StandardCharCode.backslash;
375 code[']'] = StandardCharCode.bracketright;
376 code['^'] = StandardCharCode.asciicircum;
377 code['_'] = StandardCharCode.underscore;
378 code['`'] = StandardCharCode.quoteleft;
379 code['a'] = StandardCharCode.alpha;
380 code['b'] = StandardCharCode.beta;
381 code['c'] = StandardCharCode.chi;
382 code['d'] = StandardCharCode.delta;
383 code['e'] = StandardCharCode.epsilon;
384 code['f'] = StandardCharCode.phi;
385 code['g'] = StandardCharCode.gamma;
386 code['h'] = StandardCharCode.eta;
387 code['i'] = StandardCharCode.iota;
388 code['k'] = StandardCharCode.kappa;
389 code['l'] = StandardCharCode.lambda;
390 code['m'] = StandardCharCode.mu;
391 code['n'] = StandardCharCode.nu;
392 code['o'] = StandardCharCode.omicron;
393 code['p'] = StandardCharCode.pi;
394 code['q'] = StandardCharCode.theta;
395 code['r'] = StandardCharCode.rho;
396 code['s'] = StandardCharCode.sigma;
397 code['t'] = StandardCharCode.tau;
398 code['u'] = StandardCharCode.upsilon;
399 code['w'] = StandardCharCode.omega;
400 code['x'] = StandardCharCode.xi;
401 code['y'] = StandardCharCode.psi;
402 code['z'] = StandardCharCode.zeta;
403 code['{'] = StandardCharCode.braceleft;
404 code['|'] = StandardCharCode.bar;
405 code['}'] = StandardCharCode.braceright;
406 code['~'] = StandardCharCode.mathtilde;
411 #endregion // Public Static Methods