KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webdav > lib > util > MIME2Java


1 /*
2  * $Header: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/util/MIME2Java.java,v 1.1 2004/08/02 15:45:49 unico Exp $
3  * $Revision: 1.1 $
4  * $Date: 2004/08/02 15:45:49 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

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

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

586     public static String JavaDoc convert(String JavaDoc mimeCharsetName) {
587         return (String JavaDoc)s_enchash.get(mimeCharsetName.toUpperCase());
588     }
589
590     /**
591      * Convert a Java encoding name to MIME charset name.
592      * Available values of <i>encoding</i> are "UTF8", "8859_1", "8859_2", "8859_3", "8859_4",
593      * "8859_5", "8859_6", "8859_7", "8859_8", "8859_9", "JIS", "SJIS", "EUCJIS",
594      * "GB2312", "BIG5", "KSC5601", "ISO2022KR", "KOI8_R", "CP037", "CP277", "CP278",
595      * "CP280", "CP284", "CP285", "CP297", "CP420", "CP424", "CP500", "CP870", "CP871" and "CP918".
596      * @param encoding Case insensitive Java encoding name: <code>UTF8, 8859_1, 8859_2, 8859_3,
597      * 8859_4, 8859_5, 8859_6, 8859_7, 8859_8, 8859_9, JIS, SJIS, EUCJIS,
598      * GB2312, BIG5, KSC5601, ISO2022KR, KOI8_R, CP037, CP277, CP278,
599      * CP280, CP284, CP285, CP297, CP420, CP424, CP500, CP870, CP871
600      * and CP918</code>.
601      * @return MIME charset name, or <var>null</var> if <var>encoding</var> is unknown.
602      * @see #convert
603      */

604     public static String JavaDoc reverse(String JavaDoc encoding) {
605         return (String JavaDoc)s_revhash.get(encoding.toUpperCase());
606     }
607 }
608
Popular Tags