OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [java/] [nio/] [charset/] [iconv/] [IconvMetaData.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* IconvMetaData.java --
2
   Copyright (C) 2005 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package gnu.java.nio.charset.iconv;
40
 
41
import java.util.HashMap;
42
import java.util.Vector;
43
 
44
/**
45
 * This is ugly glue. iconv doesn't have character metadata,
46
 * so we include it here.
47
 *
48
 * TODO: Add more charsets which GNU iconv and the JDK support which aren't
49
 * included here.
50
 *
51
 * @author Sven de Marothy
52
 */
53
final class IconvMetaData
54
{
55
  /**
56
   * Map of names (and aliases) to metadata instances
57
   */
58
  private static HashMap names;
59
 
60
  /**
61
   * Vector of MetaData instances
62
   */
63
  private static Vector charsets;
64
 
65
  /**
66
   * Name to use with iconv (may differ from the nio canonical.
67
   */
68
  private String iconvName;
69
 
70
  /**
71
   * Average number of bytes per char.
72
   */
73
  private float averageBperC;
74
 
75
  /**
76
   * Maximum number of bytes per char.
77
   */
78
  private float maxBperC;
79
 
80
  /**
81
   * Average number of chars per byte.
82
   */
83
  private float averageCperB;
84
 
85
  /**
86
   * Maximum number of chars per byte.
87
   */
88
  private float maxCperB;
89
 
90
  /**
91
   * NIO canonical name.
92
   */
93
  private String nioCanonical;
94
 
95
  /**
96
   * Charset aliases.
97
   */
98
  private String[] aliases;
99
 
100
  IconvMetaData(String nioCanonical, float averageBperC, float maxBperC,
101
                float averageCperB, float maxCperB, String[] aliases,
102
                String iconvName)
103
  {
104
    this.nioCanonical = nioCanonical;
105
    this.iconvName = iconvName;
106
 
107
    this.averageBperC = averageBperC;
108
    this.maxBperC = maxBperC;
109
    this.averageCperB = averageCperB;
110
    this.maxCperB = maxCperB;
111
    this.aliases = aliases;
112
 
113
    names.put(nioCanonical, this);
114
    names.put(iconvName, this);
115
    for (int i = 0; i < aliases.length; i++)
116
      names.put(aliases[i], this);
117
    charsets.add(this);
118
  }
119
 
120
  static Vector charsets()
121
  {
122
    return charsets;
123
  }
124
 
125
  String[] aliases()
126
  {
127
    return aliases;
128
  }
129
 
130
  String nioCanonical()
131
  {
132
    return nioCanonical;
133
  }
134
 
135
  String iconvName()
136
  {
137
    return iconvName;
138
  }
139
 
140
  float maxBytesPerChar()
141
  {
142
    return maxBperC;
143
  }
144
 
145
  float maxCharsPerByte()
146
  {
147
    return maxCperB;
148
  }
149
 
150
  float averageBytesPerChar()
151
  {
152
    return averageBperC;
153
  }
154
 
155
  float averageCharsPerByte()
156
  {
157
    return averageCperB;
158
  }
159
 
160
  static IconvMetaData get(String s)
161
  {
162
    return (IconvMetaData) names.get(s);
163
  }
164
 
165
  static void setup()
166
  {
167
    names = new HashMap();
168
    charsets = new Vector();
169
    new IconvMetaData("Big5", 2.0f, 2.0f, 0.5f, 1.0f,
170
                      new String[] { "big-5", "csBig5" }, "Big5");
171
 
172
    new IconvMetaData("Big5-HKSCS", 2.0f, 2.0f, 0.5f, 1.0f,
173
                      new String[] { "big5-hkscs", "Big5_HKSCS", "big5hkscs" },
174
                      "Big5-HKSCS");
175
 
176
    new IconvMetaData("EUC-CN", 2.0f, 2.0f, 0.5f, 1.0f, new String[] {  },
177
                      "EUC-CN");
178
 
179
    new IconvMetaData("EUC-JP", 3.0f, 3.0f, 0.5f, 1.0f,
180
                      new String[]
181
                      {
182
                        "eucjis", "x-eucjp", "csEUCPkdFmtjapanese", "eucjp",
183
                        "Extended_UNIX_Code_Packed_Format_for_Japanese",
184
                        "x-euc-jp", "euc_jp"
185
                      }, "EUC-JP");
186
 
187
    new IconvMetaData("EUC-KR", 2.0f, 2.0f, 0.5f, 1.0f,
188
                      new String[]
189
                      {
190
                        "ksc5601", "5601", "ksc5601_1987", "ksc_5601",
191
                        "ksc5601-1987", "euc_kr", "ks_c_5601-1987", "euckr",
192
                        "csEUCKR"
193
                      }, "EUC-KR");
194
 
195
    new IconvMetaData("EUC-TW", 4.0f, 4.0f, 2.0f, 2.0f,
196
                      new String[] { "cns11643", "euc_tw", "euctw", }, "EUC-TW");
197
 
198
    new IconvMetaData("GB18030", 4.0f, 4.0f, 1.0f, 2.0f,
199
                      new String[] { "gb18030-2000", }, "GB18030");
200
 
201
    new IconvMetaData("GBK", 2.0f, 2.0f, 0.5f, 1.0f, new String[] { "GBK" },
202
                      "GBK");
203
 
204
    new IconvMetaData("ISO-2022-CN-CNS", 4.0f, 4.0f, 2.0f, 2.0f,
205
                      new String[] { "ISO2022CN_CNS" }, "ISO-2022-CN"); // will this work?
206
 
207
    new IconvMetaData("ISO-2022-CN-GB", 4.0f, 4.0f, 2.0f, 2.0f,
208
                      new String[] { "ISO2022CN_GB" }, "ISO-2022-CN"); // same here?
209
 
210
    new IconvMetaData("ISO-2022-KR", 4.0f, 4.0f, 1.0f, 1.0f,
211
                      new String[] { "ISO2022KR", "csISO2022KR" },
212
                      "ISO-2022-KR");
213
 
214
    new IconvMetaData("ISO-8859-1", 1.0f, 1.0f, 1.0f, 1.0f,
215
                      new String[]
216
                      {
217
                        "iso-ir-100", "ISO_8859-1", "latin1", "l1", "IBM819",
218
                        "CP819", "csISOLatin1", "8859_1", "ISO8859_1",
219
                        "ISO_8859_1", "ibm-819", "ISO_8859-1:1987", "819"
220
                      }, "ISO-8859-1");
221
 
222
    new IconvMetaData("ISO-8859-13", 1.0f, 1.0f, 1.0f, 1.0f,
223
                      new String[]
224
                      {
225
                        "ISO8859_13", "8859_13", "ibm-921_P100-1995", "ibm-921",
226
                        "iso_8859_13", "iso8859_13", "iso-8859-13", "8859_13",
227
                        "cp921", "921"
228
                      }, "ISO-8859-13");
229
 
230
    new IconvMetaData("ISO-8859-15", 1.0f, 1.0f, 1.0f, 1.0f,
231
                      new String[]
232
                      {
233
                        "8859_15", "csISOlatin9", "IBM923", "cp923", "923",
234
                        "LATIN0", "csISOlatin0", "ISO8859_15_FDIS", "L9",
235
                        "IBM-923", "ISO8859-15", "LATIN9", "ISO_8859-15",
236
                        "ISO-8859-15",
237
                      }, "ISO-8859-15");
238
 
239
    new IconvMetaData("ISO-8859-2", 1.0f, 1.0f, 1.0f, 1.0f,
240
                      new String[]
241
                      {
242
                        "ISO8859_2", "8859_2", "ibm-912_P100-1995", "ibm-912",
243
                        "iso_8859_2", "iso8859_2", "iso-8859-2",
244
                        "ISO_8859-2:1987", "latin2", "csISOLatin2",
245
                        "iso-ir-101", "l2", "cp912", "912", "windows-28592"
246
                      }, "ISO-8859-2");
247
 
248
    new IconvMetaData("ISO-8859-3", 1.0f, 1.0f, 1.0f, 1.0f,
249
                      new String[]
250
                      {
251
                        "ISO8859_3", "8859_3", "ibm-913_P100-2000", "ibm-913",
252
                        "iso_8859_3", "iso8859_3", "iso-8859-3",
253
                        "ISO_8859-3:1988", "latin3", "csISOLatin3",
254
                        "iso-ir-109", "l3", "cp913", "913", "windows-28593"
255
                      }, "ISO-8859-3");
256
 
257
    new IconvMetaData("ISO-8859-4", 1.0f, 1.0f, 1.0f, 1.0f,
258
                      new String[]
259
                      {
260
                        "ISO8859_4", "8859_4", "ibm-914_P100-1995", "ibm-914",
261
                        "iso_8859_4", "iso8859_4", "iso-8859-4", "latin4",
262
                        "csISOLatin4", "iso-ir-110", "ISO_8859-4:1988", "l4",
263
                        "cp914", "914", "windows-28594"
264
                      }, "ISO-8859-4");
265
 
266
    new IconvMetaData("ISO-8859-5", 1.0f, 1.0f, 1.0f, 1.0f,
267
                      new String[]
268
                      {
269
                        "ISO8859_5", "8859_5", "ibm-915_P100-1995", "ibm-915",
270
                        "iso_8859_5", "iso8859_5", "iso-8859-5", "cyrillic",
271
                        "csISOLatinCyrillic", "iso-ir-144", "ISO_8859-5:1988",
272
                        "cp915", "915", "windows-28595"
273
                      }, "ISO-8859-5");
274
 
275
    new IconvMetaData("ISO-8859-6", 1.0f, 1.0f, 1.0f, 1.0f,
276
                      new String[]
277
                      {
278
                        "8859_6", "ibm-1089_P100-1995", "ibm-1089",
279
                        "iso_8859_6", "iso8859_6", "iso-8859-6", "arabic",
280
                        "csISOLatinArabic", "iso-ir-127", "ISO_8859-6:1987",
281
                        "ECMA-114", "ASMO-708", "8859_6", "cp1089", "1089",
282
                        "windows-28596", "ISO-8859-6-I", "ISO-8859-6-E"
283
                      }, "ISO-8859-6");
284
 
285
    new IconvMetaData("ISO-8859-7", 1.0f, 1.0f, 1.0f, 1.0f,
286
                      new String[]
287
                      {
288
                        "ISO8859_7", "8859_7", "ibm-813_P100-1995", "ibm-813",
289
                        "iso_8859_7", "iso8859_7", "iso-8859-7", "greek",
290
                        "greek8", "ELOT_928", "ECMA-118", "csISOLatinGreek",
291
                        "iso-ir-126", "ISO_8859-7:1987", "cp813", "813",
292
                        "windows-28597"
293
                      }, "ISO-8859-7");
294
 
295
    new IconvMetaData("ISO-8859-8", 1.0f, 1.0f, 1.0f, 1.0f,
296
                      new String[]
297
                      {
298
                        "ISO8859_8", "8859_8", "ibm-916_P100-1995", "ibm-916",
299
                        "iso_8859_8", "iso8859_8", "iso-8859-8", "hebrew",
300
                        "csISOLatinHebrew", "iso-ir-138", "ISO_8859-8:1988",
301
                        "ISO-8859-8-I", "ISO-8859-8-E", "cp916", "916",
302
                        "windows-28598"
303
                      }, "ISO-8859-8");
304
 
305
    new IconvMetaData("ISO-8859-9", 1.0f, 1.0f, 1.0f, 1.0f,
306
                      new String[]
307
                      {
308
                        "ISO8859_9", "8859_9", "ibm-920_P100-1995", "ibm-920",
309
                        "iso8859_9", "iso-8859-9", "iso_8859_9", "latin5",
310
                        "csISOLatin5", "iso-ir-148", "ISO_8859-9:1989", "l5",
311
                        "cp920", "920", "windows-28599", "ECMA-128"
312
                      }, "ISO-8859-9");
313
 
314
    new IconvMetaData("Johab", 2.0f, 2.0f, 0.5f, 1.0f,
315
                      new String[] { "ms1361", "ksc5601_1992", "ksc5601-1992", },
316
                      "Johab");
317
 
318
    new IconvMetaData("KOI8-R", 1.0f, 1.0f, 1.0f, 1.0f,
319
                      new String[]
320
                      {
321
                        "KOI8_R", "KOI8", "KOI-8", "KOI_8", "koi8-r", "koi8r",
322
                        "koi-8-r", "koi"
323
                      }, "KOI8-R");
324
 
325
    new IconvMetaData("Shift_JIS", 2.0f, 2.0f, 0.5f, 1.0f,
326
                      new String[]
327
                      {
328
                        "shift-jis", "x-sjis", "ms_kanji", "shift_jis",
329
                        "csShiftJIS", "sjis", "pck",
330
                      }, "Shift_JIS");
331
 
332
    new IconvMetaData("TIS-620", 1.0f, 1.0f, 1.0f, 1.0f, new String[] {  },
333
                      "TIS-620");
334
 
335
    new IconvMetaData("US-ASCII", 1.0f, 1.0f, 1.0f, 1.0f,
336
                      new String[]
337
                      {
338
                        "IBM367", "ISO646-US", "ANSI_X3.4-1986", "cp367",
339
                        "ASCII", "iso_646.irv:1983", "646", "us", "iso-ir-6",
340
                        "csASCII", "ANSI_X3.4-1968", "ISO_646.irv:1991",
341
                      }, "US-ASCII");
342
 
343
    new IconvMetaData("UTF-16", 2.0f, 4.0f, 0.5f, 1.0f,
344
                      new String[]
345
                      {
346
                        "UTF_16", "UTF16", "ISO-10646-UCS-2", "unicode",
347
                        "csUnicode", "ucs-2", "UnicodeBig"
348
                      }, "UTF-16");
349
 
350
    new IconvMetaData("UTF-16BE", 2.0f, 2.0f, 0.5f, 1.0f,
351
                      new String[]
352
                      {
353
                        "X-UTF-16BE", "UTF_16BE", "UTF16BE", "ISO-10646-UCS-2",
354
                        "x-utf-16be", "ibm-1200", "ibm-1201", "ibm-5297",
355
                        "ibm-13488", "ibm-17584", "windows-1201", "cp1200",
356
                        "cp1201", "UnicodeBigUnmarked"
357
                      }, "UTF-16BE");
358
 
359
    new IconvMetaData("UTF-16LE", 2.0f, 2.0f, 0.5f, 1.0f,
360
                      new String[]
361
                      {
362
                        "UTF_16LE", "UTF16LE", "X-UTF-16LE", "ibm-1202",
363
                        "ibm-13490", "ibm-17586", "UTF16_LittleEndian",
364
                        "UnicodeLittleUnmarked"
365
                      }, "UTF-16LE");
366
 
367
    new IconvMetaData("UTF-8", 1.1f, 4.0f, 1.0f, 2.0f,
368
                      new String[]
369
                      {
370
                        "UTF8", "ibm-1208", "ibm-1209", "ibm-5304", "ibm-5305",
371
                        "windows-65001", "cp1208"
372
                      }, "UTF-8");
373
 
374
    new IconvMetaData("windows-1250", 1.0f, 1.0f, 1.0f, 1.0f,
375
                      new String[]
376
                      {
377
                        "Windows1250", "ibm-5346_P100-1998", "ibm-5346",
378
                        "cp1250", "cp-1250", "cp_1250", "windows1250",
379
                        "windows_1250"
380
                      }, "windows-1250");
381
 
382
    new IconvMetaData("windows-1251", 1.0f, 1.0f, 1.0f, 1.0f,
383
                      new String[]
384
                      {
385
                        "Windows1251", "cp1251", "cp-1251", "cp_1251",
386
                        "windows1251", "windows_1251"
387
                      }, "windows-1251");
388
 
389
    new IconvMetaData("windows-1252", 1.0f, 1.0f, 1.0f, 1.0f,
390
                      new String[]
391
                      {
392
                        "Windows1252", "ibm-5348_P100-1997", "ibm-5348",
393
                        "windows-1252", "cp1252", "cp-1252"
394
                      }, "windows-1252");
395
 
396
    new IconvMetaData("windows-1253", 1.0f, 1.0f, 1.0f, 1.0f,
397
                      new String[]
398
                      {
399
                        "Windows1253", "cp1253", "cp-1253", "cp_1253",
400
                        "windows1253", "windows_1253"
401
                      }, "windows-1253");
402
 
403
    new IconvMetaData("windows-1254", 1.0f, 1.0f, 1.0f, 1.0f,
404
                      new String[]
405
                      {
406
                        "Windows1254", "cp1254", "cp-1254", "cp_1254",
407
                        "windows1254", "windows_1254"
408
                      }, "windows-1254");
409
 
410
    new IconvMetaData("windows-1255", 1.0f, 1.0f, 1.0f, 1.0f,
411
                      new String[]
412
                      {
413
                        "Windows1255", "cp1255", "cp-1255", "cp_1255",
414
                        "windows1255", "windows_1255"
415
                      }, "windows-1255");
416
 
417
    new IconvMetaData("windows-1256", 1.0f, 1.0f, 1.0f, 1.0f,
418
                      new String[]
419
                      {
420
                        "Windows1255", "cp1256", "cp-1256", "cp_1256",
421
                        "windows1256", "windows_1256"
422
                      }, "windows-1256");
423
 
424
    new IconvMetaData("windows-1257", 1.0f, 1.0f, 1.0f, 1.0f,
425
                      new String[]
426
                      {
427
                        "Windows1255", "cp1257", "cp-1257", "cp_1257",
428
                        "windows1257", "windows_1257"
429
                      }, "windows-1257");
430
 
431
    new IconvMetaData("windows-1258", 1.0f, 1.0f, 1.0f, 1.0f,
432
                      new String[]
433
                      {
434
                        "Windows1255", "cp1258", "cp-1258", "cp_1258",
435
                        "windows1258", "windows_1258"
436
                      }, "windows-1258");
437
 
438
    new IconvMetaData("windows-936", 2.0f, 2.0f, 0.5f, 1.0f,
439
                      new String[] { "cp936", "ms-936", "ms936", "ms_936" },
440
                      "windows-936");
441
 
442
    new IconvMetaData("windows-949", 2.0f, 2.0f, 0.5f, 1.0f,
443
                      new String[] { "cp949", "ms-949", "ms_949", "ms949" },
444
                      "cp949");
445
 
446
    new IconvMetaData("windows-950", 2.0f, 2.0f, 0.5f, 1.0f,
447
                      new String[] { "cp950", "ms_950", "ms-950", "ms950", },
448
                      "cp950");
449
  }
450
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.