KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > util > xml > MIME2Java


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the docs/licenses/apache-1.1.txt file.
7  */

8
9 package org.jboss.util.xml;
10
11 import java.util.*;
12
13 /**
14  * MIME2Java is a convenience class which handles conversions between MIME charset names
15  * and Java encoding names.
16  * <p>The supported XML encodings are the intersection of XML-supported code sets and those
17  * supported in JDK 1.1.
18  * <p>MIME charset names are used on <var>xmlEncoding</var> parameters to methods such
19  * as <code>TXDocument#setEncoding</code> and <code>DTD#setEncoding</code>.
20  * <p>Java encoding names are used on <var>encoding</var> parameters to
21  * methods such as <code>TXDocument#printWithFormat</code> and <code>DTD#printExternal</code>.
22  * <P>
23  * <TABLE BORDER="0" WIDTH="100%">
24  * <TR>
25  * <TD WIDTH="33%">
26  * <P ALIGN="CENTER"><B>Common Name</B>
27  * </TD>
28  * <TD WIDTH="15%">
29  * <P ALIGN="CENTER"><B>Use this name in XML files</B>
30  * </TD>
31  * <TD WIDTH="12%">
32  * <P ALIGN="CENTER"><B>Name Type</B>
33  * </TD>
34  * <TD WIDTH="31%">
35  * <P ALIGN="CENTER"><B>Xerces converts to this Java Encoder Name</B>
36  * </TD>
37  * </TR>
38  * <TR>
39  * <TD WIDTH="33%">8 bit Unicode</TD>
40  * <TD WIDTH="15%">
41  * <P ALIGN="CENTER">UTF-8
42  * </TD>
43  * <TD WIDTH="12%">
44  * <P ALIGN="CENTER">IANA
45  * </TD>
46  * <TD WIDTH="31%">
47  * <P ALIGN="CENTER">UTF8
48  * </TD>
49  * </TR>
50  * <TR>
51  * <TD WIDTH="33%">ISO Latin 1</TD>
52  * <TD WIDTH="15%">
53  * <P ALIGN="CENTER">ISO-8859-1
54  * </TD>
55  * <TD WIDTH="12%">
56  * <P ALIGN="CENTER">MIME
57  * </TD>
58  * <TD WIDTH="31%">
59  * <P ALIGN="CENTER">ISO-8859-1
60  * </TD>
61  * </TR>
62  * <TR>
63  * <TD WIDTH="33%">ISO Latin 2</TD>
64  * <TD WIDTH="15%">
65  * <P ALIGN="CENTER">ISO-8859-2
66  * </TD>
67  * <TD WIDTH="12%">
68  * <P ALIGN="CENTER">MIME
69  * </TD>
70  * <TD WIDTH="31%">
71  * <P ALIGN="CENTER">ISO-8859-2
72  * </TD>
73  * </TR>
74  * <TR>
75  * <TD WIDTH="33%">ISO Latin 3</TD>
76  * <TD WIDTH="15%">
77  * <P ALIGN="CENTER">ISO-8859-3
78  * </TD>
79  * <TD WIDTH="12%">
80  * <P ALIGN="CENTER">MIME
81  * </TD>
82  * <TD WIDTH="31%">
83  * <P ALIGN="CENTER">ISO-8859-3
84  * </TD>
85  * </TR>
86  * <TR>
87  * <TD WIDTH="33%">ISO Latin 4</TD>
88  * <TD WIDTH="15%">
89  * <P ALIGN="CENTER">ISO-8859-4
90  * </TD>
91  * <TD WIDTH="12%">
92  * <P ALIGN="CENTER">MIME
93  * </TD>
94  * <TD WIDTH="31%">
95  * <P ALIGN="CENTER">ISO-8859-4
96  * </TD>
97  * </TR>
98  * <TR>
99  * <TD WIDTH="33%">ISO Latin Cyrillic</TD>
100  * <TD WIDTH="15%">
101  * <P ALIGN="CENTER">ISO-8859-5
102  * </TD>
103  * <TD WIDTH="12%">
104  * <P ALIGN="CENTER">MIME
105  * </TD>
106  * <TD WIDTH="31%">
107  * <P ALIGN="CENTER">ISO-8859-5
108  * </TD>
109  * </TR>
110  * <TR>
111  * <TD WIDTH="33%">ISO Latin Arabic</TD>
112  * <TD WIDTH="15%">
113  * <P ALIGN="CENTER">ISO-8859-6
114  * </TD>
115  * <TD WIDTH="12%">
116  * <P ALIGN="CENTER">MIME
117  * </TD>
118  * <TD WIDTH="31%">
119  * <P ALIGN="CENTER">ISO-8859-6
120  * </TD>
121  * </TR>
122  * <TR>
123  * <TD WIDTH="33%">ISO Latin Greek</TD>
124  * <TD WIDTH="15%">
125  * <P ALIGN="CENTER">ISO-8859-7
126  * </TD>
127  * <TD WIDTH="12%">
128  * <P ALIGN="CENTER">MIME
129  * </TD>
130  * <TD WIDTH="31%">
131  * <P ALIGN="CENTER">ISO-8859-7
132  * </TD>
133  * </TR>
134  * <TR>
135  * <TD WIDTH="33%">ISO Latin Hebrew</TD>
136  * <TD WIDTH="15%">
137  * <P ALIGN="CENTER">ISO-8859-8
138  * </TD>
139  * <TD WIDTH="12%">
140  * <P ALIGN="CENTER">MIME
141  * </TD>
142  * <TD WIDTH="31%">
143  * <P ALIGN="CENTER">ISO-8859-8
144  * </TD>
145  * </TR>
146  * <TR>
147  * <TD WIDTH="33%">ISO Latin 5</TD>
148  * <TD WIDTH="15%">
149  * <P ALIGN="CENTER">ISO-8859-9
150  * </TD>
151  * <TD WIDTH="12%">
152  * <P ALIGN="CENTER">MIME
153  * </TD>
154  * <TD WIDTH="31%">
155  * <P ALIGN="CENTER">ISO-8859-9
156  * </TD>
157  * </TR>
158  * <TR>
159  * <TD WIDTH="33%">EBCDIC: US</TD>
160  * <TD WIDTH="15%">
161  * <P ALIGN="CENTER">ebcdic-cp-us
162  * </TD>
163  * <TD WIDTH="12%">
164  * <P ALIGN="CENTER">IANA
165  * </TD>
166  * <TD WIDTH="31%">
167  * <P ALIGN="CENTER">cp037
168  * </TD>
169  * </TR>
170  * <TR>
171  * <TD WIDTH="33%">EBCDIC: Canada</TD>
172  * <TD WIDTH="15%">
173  * <P ALIGN="CENTER">ebcdic-cp-ca
174  * </TD>
175  * <TD WIDTH="12%">
176  * <P ALIGN="CENTER">IANA
177  * </TD>
178  * <TD WIDTH="31%">
179  * <P ALIGN="CENTER">cp037
180  * </TD>
181  * </TR>
182  * <TR>
183  * <TD WIDTH="33%">EBCDIC: Netherlands</TD>
184  * <TD WIDTH="15%">
185  * <P ALIGN="CENTER">ebcdic-cp-nl
186  * </TD>
187  * <TD WIDTH="12%">
188  * <P ALIGN="CENTER">IANA
189  * </TD>
190  * <TD WIDTH="31%">
191  * <P ALIGN="CENTER">cp037
192  * </TD>
193  * </TR>
194  * <TR>
195  * <TD WIDTH="33%">EBCDIC: Denmark</TD>
196  * <TD WIDTH="15%">
197  * <P ALIGN="CENTER">ebcdic-cp-dk
198  * </TD>
199  * <TD WIDTH="12%">
200  * <P ALIGN="CENTER">IANA
201  * </TD>
202  * <TD WIDTH="31%">
203  * <P ALIGN="CENTER">cp277
204  * </TD>
205  * </TR>
206  * <TR>
207  * <TD WIDTH="33%">EBCDIC: Norway</TD>
208  * <TD WIDTH="15%">
209  * <P ALIGN="CENTER">ebcdic-cp-no
210  * </TD>
211  * <TD WIDTH="12%">
212  * <P ALIGN="CENTER">IANA
213  * </TD>
214  * <TD WIDTH="31%">
215  * <P ALIGN="CENTER">cp277
216  * </TD>
217  * </TR>
218  * <TR>
219  * <TD WIDTH="33%">EBCDIC: Finland</TD>
220  * <TD WIDTH="15%">
221  * <P ALIGN="CENTER">ebcdic-cp-fi
222  * </TD>
223  * <TD WIDTH="12%">
224  * <P ALIGN="CENTER">IANA
225  * </TD>
226  * <TD WIDTH="31%">
227  * <P ALIGN="CENTER">cp278
228  * </TD>
229  * </TR>
230  * <TR>
231  * <TD WIDTH="33%">EBCDIC: Sweden</TD>
232  * <TD WIDTH="15%">
233  * <P ALIGN="CENTER">ebcdic-cp-se
234  * </TD>
235  * <TD WIDTH="12%">
236  * <P ALIGN="CENTER">IANA
237  * </TD>
238  * <TD WIDTH="31%">
239  * <P ALIGN="CENTER">cp278
240  * </TD>
241  * </TR>
242  * <TR>
243  * <TD WIDTH="33%">EBCDIC: Italy</TD>
244  * <TD WIDTH="15%">
245  * <P ALIGN="CENTER">ebcdic-cp-it
246  * </TD>
247  * <TD WIDTH="12%">
248  * <P ALIGN="CENTER">IANA
249  * </TD>
250  * <TD WIDTH="31%">
251  * <P ALIGN="CENTER">cp280
252  * </TD>
253  * </TR>
254  * <TR>
255  * <TD WIDTH="33%">EBCDIC: Spain, Latin America</TD>
256  * <TD WIDTH="15%">
257  * <P ALIGN="CENTER">ebcdic-cp-es
258  * </TD>
259  * <TD WIDTH="12%">
260  * <P ALIGN="CENTER">IANA
261  * </TD>
262  * <TD WIDTH="31%">
263  * <P ALIGN="CENTER">cp284
264  * </TD>
265  * </TR>
266  * <TR>
267  * <TD WIDTH="33%">EBCDIC: Great Britain</TD>
268  * <TD WIDTH="15%">
269  * <P ALIGN="CENTER">ebcdic-cp-gb
270  * </TD>
271  * <TD WIDTH="12%">
272  * <P ALIGN="CENTER">IANA
273  * </TD>
274  * <TD WIDTH="31%">
275  * <P ALIGN="CENTER">cp285
276  * </TD>
277  * </TR>
278  * <TR>
279  * <TD WIDTH="33%">EBCDIC: France</TD>
280  * <TD WIDTH="15%">
281  * <P ALIGN="CENTER">ebcdic-cp-fr
282  * </TD>
283  * <TD WIDTH="12%">
284  * <P ALIGN="CENTER">IANA
285  * </TD>
286  * <TD WIDTH="31%">
287  * <P ALIGN="CENTER">cp297
288  * </TD>
289  * </TR>
290  * <TR>
291  * <TD WIDTH="33%">EBCDIC: Arabic</TD>
292  * <TD WIDTH="15%">
293  * <P ALIGN="CENTER">ebcdic-cp-ar1
294  * </TD>
295  * <TD WIDTH="12%">
296  * <P ALIGN="CENTER">IANA
297  * </TD>
298  * <TD WIDTH="31%">
299  * <P ALIGN="CENTER">cp420
300  * </TD>
301  * </TR>
302  * <TR>
303  * <TD WIDTH="33%">EBCDIC: Hebrew</TD>
304  * <TD WIDTH="15%">
305  * <P ALIGN="CENTER">ebcdic-cp-he
306  * </TD>
307  * <TD WIDTH="12%">
308  * <P ALIGN="CENTER">IANA
309  * </TD>
310  * <TD WIDTH="31%">
311  * <P ALIGN="CENTER">cp424
312  * </TD>
313  * </TR>
314  * <TR>
315  * <TD WIDTH="33%">EBCDIC: Switzerland</TD>
316  * <TD WIDTH="15%">
317  * <P ALIGN="CENTER">ebcdic-cp-ch
318  * </TD>
319  * <TD WIDTH="12%">
320  * <P ALIGN="CENTER">IANA
321  * </TD>
322  * <TD WIDTH="31%">
323  * <P ALIGN="CENTER">cp500
324  * </TD>
325  * </TR>
326  * <TR>
327  * <TD WIDTH="33%">EBCDIC: Roece</TD>
328  * <TD WIDTH="15%">
329  * <P ALIGN="CENTER">ebcdic-cp-roece
330  * </TD>
331  * <TD WIDTH="12%">
332  * <P ALIGN="CENTER">IANA
333  * </TD>
334  * <TD WIDTH="31%">
335  * <P ALIGN="CENTER">cp870
336  * </TD>
337  * </TR>
338  * <TR>
339  * <TD WIDTH="33%">EBCDIC: Yogoslavia</TD>
340  * <TD WIDTH="15%">
341  * <P ALIGN="CENTER">ebcdic-cp-yu
342  * </TD>
343  * <TD WIDTH="12%">
344  * <P ALIGN="CENTER">IANA
345  * </TD>
346  * <TD WIDTH="31%">
347  * <P ALIGN="CENTER">cp870
348  * </TD>
349  * </TR>
350  * <TR>
351  * <TD WIDTH="33%">EBCDIC: Iceland</TD>
352  * <TD WIDTH="15%">
353  * <P ALIGN="CENTER">ebcdic-cp-is
354  * </TD>
355  * <TD WIDTH="12%">
356  * <P ALIGN="CENTER">IANA
357  * </TD>
358  * <TD WIDTH="31%">
359  * <P ALIGN="CENTER">cp871
360  * </TD>
361  * </TR>
362  * <TR>
363  * <TD WIDTH="33%">EBCDIC: Urdu</TD>
364  * <TD WIDTH="15%">
365  * <P ALIGN="CENTER">ebcdic-cp-ar2
366  * </TD>
367  * <TD WIDTH="12%">
368  * <P ALIGN="CENTER">IANA
369  * </TD>
370  * <TD WIDTH="31%">
371  * <P ALIGN="CENTER">cp918
372  * </TD>
373  * </TR>
374  * <TR>
375  * <TD WIDTH="33%">Chinese for PRC, mixed 1/2 byte</TD>
376  * <TD WIDTH="15%">
377  * <P ALIGN="CENTER">gb2312
378  * </TD>
379  * <TD WIDTH="12%">
380  * <P ALIGN="CENTER">MIME
381  * </TD>
382  * <TD WIDTH="31%">
383  * <P ALIGN="CENTER">GB2312
384  * </TD>
385  * </TR>
386  * <TR>
387  * <TD WIDTH="33%">Extended Unix Code, packed for Japanese</TD>
388  * <TD WIDTH="15%">
389  * <P ALIGN="CENTER">euc-jp
390  * </TD>
391  * <TD WIDTH="12%">
392  * <P ALIGN="CENTER">MIME
393  * </TD>
394  * <TD WIDTH="31%">
395  * <P ALIGN="CENTER">eucjis
396  * </TD>
397  * </TR>
398  * <TR>
399  * <TD WIDTH="33%">Japanese: iso-2022-jp</TD>
400  * <TD WIDTH="15%">
401  * <P ALIGN="CENTER">iso-2020-jp
402  * </TD>
403  * <TD WIDTH="12%">
404  * <P ALIGN="CENTER">MIME
405  * </TD>
406  * <TD WIDTH="31%">
407  * <P ALIGN="CENTER">JIS
408  * </TD>
409  * </TR>
410  * <TR>
411  * <TD WIDTH="33%">Japanese: Shift JIS</TD>
412  * <TD WIDTH="15%">
413  * <P ALIGN="CENTER">Shift_JIS
414  * </TD>
415  * <TD WIDTH="12%">
416  * <P ALIGN="CENTER">MIME
417  * </TD>
418  * <TD WIDTH="31%">
419  * <P ALIGN="CENTER">SJIS
420  * </TD>
421  * </TR>
422  * <TR>
423  * <TD WIDTH="33%">Japanese Windows: An extension of Shift JIS</TD>
424  * <TD WIDTH="15%">
425  * <P ALIGN="CENTER">Windows-31J
426  * </TD>
427  * <TD WIDTH="12%">
428  * <P ALIGN="CENTER">MIME
429  * </TD>
430  * <TD WIDTH="31%">
431  * <P ALIGN="CENTER">MS932 (since JDK 1.2)
432  * </TD>
433  * </TR>
434  * <TR>
435  * <TD WIDTH="33%">Chinese: Big5</TD>
436  * <TD WIDTH="15%">
437  * <P ALIGN="CENTER">Big5
438  * </TD>
439  * <TD WIDTH="12%">
440  * <P ALIGN="CENTER">MIME
441  * </TD>
442  * <TD WIDTH="31%">
443  * <P ALIGN="CENTER">Big5
444  * </TD>
445  * </TR>
446  * <TR>
447  * <TD WIDTH="33%">Extended Unix Code, packed for Korean</TD>
448  * <TD WIDTH="15%">
449  * <P ALIGN="CENTER">euc-kr
450  * </TD>
451  * <TD WIDTH="12%">
452  * <P ALIGN="CENTER">MIME
453  * </TD>
454  * <TD WIDTH="31%">
455  * <P ALIGN="CENTER">iso2022kr
456  * </TD>
457  * </TR>
458  * <TR>
459  * <TD WIDTH="33%">Cyrillic</TD>
460  * <TD WIDTH="15%">
461  * <P ALIGN="CENTER">koi8-r
462  * </TD>
463  * <TD WIDTH="12%">
464  * <P ALIGN="CENTER">MIME
465  * </TD>
466  * <TD WIDTH="31%">
467  * <P ALIGN="CENTER">koi8-r
468  * </TD>
469  * </TR>
470  * </TABLE>
471  *
472  * @version $Id: MIME2Java.java,v 1.1.28.1 2005/04/06 20:27:24 starksm Exp $
473  * @version ORIGINAL - MIME2Java.java,v 1.2 2000/12/14 19:21:46 lehors
474  * @author TAMURA Kent &lt;kent@trl.ibm.co.jp&gt;
475  */

476 public class MIME2Java {
477     
478     static private Hashtable s_enchash;
479     static private Hashtable s_revhash;
480     
481     static {
482         s_enchash = new Hashtable();
483         // <preferred MIME name (uppercase)>, <Java encoding name>
484
s_enchash.put("UTF-8", "UTF8");
485         s_enchash.put("US-ASCII", "ASCII");
486         s_enchash.put("ISO-8859-1", "8859_1");
487         s_enchash.put("ISO-8859-2", "8859_2");
488         s_enchash.put("ISO-8859-3", "8859_3");
489         s_enchash.put("ISO-8859-4", "8859_4");
490         s_enchash.put("ISO-8859-5", "8859_5");
491         s_enchash.put("ISO-8859-6", "8859_6");
492         s_enchash.put("ISO-8859-7", "8859_7");
493         s_enchash.put("ISO-8859-8", "8859_8");
494         s_enchash.put("ISO-8859-9", "8859_9");
495         s_enchash.put("ISO-2022-JP", "JIS");
496         s_enchash.put("SHIFT_JIS", "SJIS");
497         /**
498          * MS932 is suitable for Windows-31J,
499          * but JDK 1.1.x does not support MS932.
500          */

501         String JavaDoc version = System.getProperty("java.version");
502         if (version.equals("1.1") || version.startsWith("1.1.")) {
503             s_enchash.put("WINDOWS-31J", "SJIS");
504         } else {
505             s_enchash.put("WINDOWS-31J", "MS932");
506         }
507         s_enchash.put("EUC-JP", "EUCJIS");
508         s_enchash.put("GB2312", "GB2312");
509         s_enchash.put("BIG5", "Big5");
510         s_enchash.put("EUC-KR", "KSC5601");
511         s_enchash.put("ISO-2022-KR", "ISO2022KR");
512         s_enchash.put("KOI8-R", "KOI8_R");
513
514         s_enchash.put("EBCDIC-CP-US", "CP037");
515         s_enchash.put("EBCDIC-CP-CA", "CP037");
516         s_enchash.put("EBCDIC-CP-NL", "CP037");
517         s_enchash.put("EBCDIC-CP-DK", "CP277");
518         s_enchash.put("EBCDIC-CP-NO", "CP277");
519         s_enchash.put("EBCDIC-CP-FI", "CP278");
520         s_enchash.put("EBCDIC-CP-SE", "CP278");
521         s_enchash.put("EBCDIC-CP-IT", "CP280");
522         s_enchash.put("EBCDIC-CP-ES", "CP284");
523         s_enchash.put("EBCDIC-CP-GB", "CP285");
524         s_enchash.put("EBCDIC-CP-FR", "CP297");
525         s_enchash.put("EBCDIC-CP-AR1", "CP420");
526         s_enchash.put("EBCDIC-CP-HE", "CP424");
527         s_enchash.put("EBCDIC-CP-CH", "CP500");
528         s_enchash.put("EBCDIC-CP-ROECE", "CP870");
529         s_enchash.put("EBCDIC-CP-YU", "CP870");
530         s_enchash.put("EBCDIC-CP-IS", "CP871");
531         s_enchash.put("EBCDIC-CP-AR2", "CP918");
532
533                                                 // j:CNS11643 -> EUC-TW?
534
// ISO-2022-CN? ISO-2022-CN-EXT?
535

536         s_revhash = new Hashtable();
537         // <Java encoding name (uppercase)>, <preferred MIME name>
538
s_revhash.put("UTF8", "UTF-8");
539         s_revhash.put("ASCII", "US-ASCII");
540         s_revhash.put("8859_1", "ISO-8859-1");
541         s_revhash.put("8859_2", "ISO-8859-2");
542         s_revhash.put("8859_3", "ISO-8859-3");
543         s_revhash.put("8859_4", "ISO-8859-4");
544         s_revhash.put("8859_5", "ISO-8859-5");
545         s_revhash.put("8859_6", "ISO-8859-6");
546         s_revhash.put("8859_7", "ISO-8859-7");
547         s_revhash.put("8859_8", "ISO-8859-8");
548         s_revhash.put("8859_9", "ISO-8859-9");
549         s_revhash.put("JIS", "ISO-2022-JP");
550         s_revhash.put("SJIS", "Shift_JIS");
551         s_revhash.put("MS932", "WINDOWS-31J");
552         s_revhash.put("EUCJIS", "EUC-JP");
553         s_revhash.put("GB2312", "GB2312");
554         s_revhash.put("BIG5", "Big5");
555         s_revhash.put("KSC5601", "EUC-KR");
556         s_revhash.put("ISO2022KR", "ISO-2022-KR");
557         s_revhash.put("KOI8_R", "KOI8-R");
558
559         s_revhash.put("CP037", "EBCDIC-CP-US");
560         s_revhash.put("CP037", "EBCDIC-CP-CA");
561         s_revhash.put("CP037", "EBCDIC-CP-NL");
562         s_revhash.put("CP277", "EBCDIC-CP-DK");
563         s_revhash.put("CP277", "EBCDIC-CP-NO");
564         s_revhash.put("CP278", "EBCDIC-CP-FI");
565         s_revhash.put("CP278", "EBCDIC-CP-SE");
566         s_revhash.put("CP280", "EBCDIC-CP-IT");
567         s_revhash.put("CP284", "EBCDIC-CP-ES");
568         s_revhash.put("CP285", "EBCDIC-CP-GB");
569         s_revhash.put("CP297", "EBCDIC-CP-FR");
570         s_revhash.put("CP420", "EBCDIC-CP-AR1");
571         s_revhash.put("CP424", "EBCDIC-CP-HE");
572         s_revhash.put("CP500", "EBCDIC-CP-CH");
573         s_revhash.put("CP870", "EBCDIC-CP-ROECE");
574         s_revhash.put("CP870", "EBCDIC-CP-YU");
575         s_revhash.put("CP871", "EBCDIC-CP-IS");
576         s_revhash.put("CP918", "EBCDIC-CP-AR2");
577     }
578
579     private MIME2Java() {
580     }
581
582     /**
583      * Convert a MIME charset name, also known as an XML encoding name, to a Java encoding name.
584      * @param mimeCharsetName Case insensitive MIME charset name: <code>UTF-8, US-ASCII, ISO-8859-1,
585      * ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6,
586      * ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-2022-JP, Shift_JIS, Windows-31J
587      * EUC-JP, GB2312, Big5, EUC-KR, ISO-2022-KR, KOI8-R,
588      * EBCDIC-CP-US, EBCDIC-CP-CA, EBCDIC-CP-NL, EBCDIC-CP-DK,
589      * EBCDIC-CP-NO, EBCDIC-CP-FI, EBCDIC-CP-SE, EBCDIC-CP-IT,
590      * EBCDIC-CP-ES, EBCDIC-CP-GB, EBCDIC-CP-FR, EBCDIC-CP-AR1,
591      * EBCDIC-CP-HE, EBCDIC-CP-CH, EBCDIC-CP-ROECE, EBCDIC-CP-YU,
592      * EBCDIC-CP-IS and EBCDIC-CP-AR2</code>.
593      * @return Java encoding name, or <var>null</var> if <var>mimeCharsetName</var>
594      * is unknown.
595      * @see #reverse
596      */

597     public static String JavaDoc convert(String JavaDoc mimeCharsetName) {
598         return (String JavaDoc)s_enchash.get(mimeCharsetName.toUpperCase());
599     }
600
601     /**
602      * Convert a Java encoding name to MIME charset name.
603      * Available values of <i>encoding</i> are "UTF8", "8859_1", "8859_2", "8859_3", "8859_4",
604      * "8859_5", "8859_6", "8859_7", "8859_8", "8859_9", "JIS", "SJIS", "MS932", "EUCJIS",
605      * "GB2312", "BIG5", "KSC5601", "ISO2022KR", "KOI8_R", "CP037", "CP277", "CP278",
606      * "CP280", "CP284", "CP285", "CP297", "CP420", "CP424", "CP500", "CP870", "CP871" and "CP918".
607      * @param encoding Case insensitive Java encoding name: <code>UTF8, 8859_1, 8859_2, 8859_3,
608      * 8859_4, 8859_5, 8859_6, 8859_7, 8859_8, 8859_9, JIS, SJIS, MS932, EUCJIS,
609      * GB2312, BIG5, KSC5601, ISO2022KR, KOI8_R, CP037, CP277, CP278,
610      * CP280, CP284, CP285, CP297, CP420, CP424, CP500, CP870, CP871
611      * and CP918</code>.
612      * @return MIME charset name, or <var>null</var> if <var>encoding</var> is unknown.
613      * @see #convert
614      */

615     public static String JavaDoc reverse(String JavaDoc encoding) {
616         return (String JavaDoc)s_revhash.get(encoding.toUpperCase());
617     }
618 }
619
Popular Tags