1:
37:
38:
39: package ;
40:
41: import ;
42:
43: import ;
44: import ;
45: import ;
46:
47:
57: public class CharSets_OSF
58: {
59: public static final int ASCII = 0x00010020;
60: public static final int ISO8859_1 = 0x00010001;
61: public static final int ISO8859_2 = 0x00010002;
62: public static final int ISO8859_3 = 0x00010003;
63: public static final int ISO8859_4 = 0x00010004;
64: public static final int ISO8859_5 = 0x00010005;
65: public static final int ISO8859_6 = 0x00010006;
66: public static final int ISO8859_7 = 0x00010007;
67: public static final int ISO8859_8 = 0x00010008;
68: public static final int ISO8859_9 = 0x00010009;
69: public static final int ISO8859_15_FDIS = 0x0001000F;
70: public static final int UTF8 = 0x05010001;
71: public static final int UTF16 = 0x00010109;
72: public static final int UCS2 = 0x00010100;
73: public static final int Cp1047 = 0x10020417;
74: public static final int Cp1250 = 0x100204E2;
75: public static final int Cp1251 = 0x100204E3;
76: public static final int Cp1252 = 0x100204E4;
77: public static final int Cp1253 = 0x100204E5;
78: public static final int Cp1254 = 0x100204E6;
79: public static final int Cp1255 = 0x100204E7;
80: public static final int Cp1256 = 0x100204E8;
81: public static final int Cp1257 = 0x100204E9;
82: public static final int Cp1363 = 0x10020553;
83: public static final int Cp1363C = 0x10020553;
84: public static final int Cp1381 = 0x10020565;
85: public static final int Cp1383 = 0x10020567;
86: public static final int Cp1386 = 0x1002056A;
87: public static final int Cp33722 = 0x100283BA;
88: public static final int Cp33722C = 0x100283BA;
89: public static final int Cp930 = 0x100203A2;
90: public static final int Cp943 = 0x100203AF;
91: public static final int Cp943C = 0x100203AF;
92: public static final int Cp949 = 0x100203B5;
93: public static final int Cp949C = 0x100203B5;
94: public static final int Cp950 = 0x100203B6;
95: public static final int Cp964 = 0x100203C4;
96: public static final int Cp970 = 0x100203CA;
97: public static final int EUC_JP = 0x00030010;
98: public static final int EUC_KR = 0x0004000A;
99: public static final int EUC_TW = 0x00050010;
100:
101:
104: public static final int NATIVE_CHARACTER = ISO8859_1;
105:
106:
109: public static final int NATIVE_WIDE_CHARACTER = UTF16;
110:
111:
114: private static Hashtable code_to_string;
115:
116:
119: private static Hashtable string_to_code;
120:
121:
126: public static int getCode(String name)
127: {
128: if (string_to_code == null)
129: makeMap();
130:
131: Integer code = (Integer) string_to_code.get(name);
132: return code == null ? 0 : code.intValue();
133: }
134:
135:
140: public static String getName(int code)
141: {
142: if (code_to_string == null)
143: makeMap();
144: return (String) code_to_string.get(new Integer(code));
145: }
146:
147:
151: public static int[] getSupportedCharSets()
152: {
153: Set supported_sets = Charset.availableCharsets().keySet();
154: int[] supported = new int[ supported_sets.size() ];
155: Iterator iter = supported_sets.iterator();
156:
157: int i = 0;
158: int code;
159: while (iter.hasNext())
160: {
161: code = getCode(iter.next().toString());
162: if (code > 0)
163: supported [ i++ ] = code;
164: }
165:
166:
167: int[] f = new int[ i ];
168: System.arraycopy(supported, 0, f, 0, f.length);
169:
170: return f;
171: }
172:
173:
176: private static void makeMap()
177: {
178: code_to_string = new Hashtable();
179: string_to_code = new Hashtable();
180:
181:
182: put(ASCII, "US-ASCII");
183: put(ISO8859_1, "ISO-8859-1");
184: put(UTF16, "UTF-16");
185:
186:
187: put(ISO8859_2, "ISO-8859-2");
188: put(ISO8859_3, "ISO-8859-3");
189: put(ISO8859_4, "ISO-8859-4");
190: put(ISO8859_5, "ISO-8859-5");
191: put(ISO8859_6, "ISO-8859-6");
192: put(ISO8859_7, "ISO-8859-7");
193: put(ISO8859_8, "ISO-8859-8");
194: put(ISO8859_9, "ISO-8859-9");
195:
196: put(UTF8, "UTF-8");
197: put(UCS2, "UCS-2");
198:
199: put(ISO8859_15_FDIS, "ISO8859-15-FDIS");
200:
201: put(Cp1047, "Cp1047");
202: put(Cp1250, "Cp1250");
203: put(Cp1251, "Cp1251");
204: put(Cp1252, "Cp1252");
205: put(Cp1253, "Cp1253");
206: put(Cp1254, "Cp1254");
207: put(Cp1255, "Cp1255");
208: put(Cp1256, "Cp1256");
209: put(Cp1257, "Cp1257");
210: put(Cp1363, "Cp1363");
211: put(Cp1363C, "Cp1363C");
212: put(Cp1381, "Cp1381");
213: put(Cp1383, "Cp1383");
214: put(Cp1386, "Cp1386");
215: put(Cp33722, "Cp33722");
216: put(Cp33722C, "Cp33722C");
217: put(Cp930, "Cp930");
218: put(Cp943, "Cp943");
219: put(Cp943C, "Cp943C");
220: put(Cp949, "Cp949");
221: put(Cp949C, "Cp949C");
222: put(Cp950, "Cp950");
223: put(Cp964, "Cp964");
224: put(Cp970, "Cp970");
225:
226: put(EUC_JP, "EUC-JP");
227: put(EUC_KR, "EUC-KR");
228: put(EUC_TW, "EUC-TW");
229: }
230:
231: private static void put(int code, String name)
232: {
233: Integer ic = new Integer(code);
234:
235: code_to_string.put(ic, name);
236: string_to_code.put(name, ic);
237: }
238: }