001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.util;
019:
020: import java.util.*;
021:
022: /**
023: * MIME2Java is a convenience class which handles conversions between MIME charset names
024: * and Java encoding names.
025: * <p>The supported XML encodings are the intersection of XML-supported code sets and those
026: * supported in JDK 1.1.
027: * <p>MIME charset names are used on <var>xmlEncoding</var> parameters to methods such
028: * as <code>TXDocument#setEncoding</code> and <code>DTD#setEncoding</code>.
029: * <p>Java encoding names are used on <var>encoding</var> parameters to
030: * methods such as <code>TXDocument#printWithFormat</code> and <code>DTD#printExternal</code>.
031: * <P>
032: * <TABLE BORDER="0" WIDTH="100%">
033: * <TR>
034: * <TD WIDTH="33%">
035: * <P ALIGN="CENTER"><B>Common Name</B>
036: * </TD>
037: * <TD WIDTH="15%">
038: * <P ALIGN="CENTER"><B>Use this name in XML files</B>
039: * </TD>
040: * <TD WIDTH="12%">
041: * <P ALIGN="CENTER"><B>Name Type</B>
042: * </TD>
043: * <TD WIDTH="31%">
044: * <P ALIGN="CENTER"><B>Xerces converts to this Java Encoder Name</B>
045: * </TD>
046: * </TR>
047: * <TR>
048: * <TD WIDTH="33%">8 bit Unicode</TD>
049: * <TD WIDTH="15%">
050: * <P ALIGN="CENTER">UTF-8
051: * </TD>
052: * <TD WIDTH="12%">
053: * <P ALIGN="CENTER">IANA
054: * </TD>
055: * <TD WIDTH="31%">
056: * <P ALIGN="CENTER">UTF8
057: * </TD>
058: * </TR>
059: * <TR>
060: * <TD WIDTH="33%">ISO Latin 1</TD>
061: * <TD WIDTH="15%">
062: * <P ALIGN="CENTER">ISO-8859-1
063: * </TD>
064: * <TD WIDTH="12%">
065: * <P ALIGN="CENTER">MIME
066: * </TD>
067: * <TD WIDTH="31%">
068: * <P ALIGN="CENTER">ISO-8859-1
069: * </TD>
070: * </TR>
071: * <TR>
072: * <TD WIDTH="33%">ISO Latin 2</TD>
073: * <TD WIDTH="15%">
074: * <P ALIGN="CENTER">ISO-8859-2
075: * </TD>
076: * <TD WIDTH="12%">
077: * <P ALIGN="CENTER">MIME
078: * </TD>
079: * <TD WIDTH="31%">
080: * <P ALIGN="CENTER">ISO-8859-2
081: * </TD>
082: * </TR>
083: * <TR>
084: * <TD WIDTH="33%">ISO Latin 3</TD>
085: * <TD WIDTH="15%">
086: * <P ALIGN="CENTER">ISO-8859-3
087: * </TD>
088: * <TD WIDTH="12%">
089: * <P ALIGN="CENTER">MIME
090: * </TD>
091: * <TD WIDTH="31%">
092: * <P ALIGN="CENTER">ISO-8859-3
093: * </TD>
094: * </TR>
095: * <TR>
096: * <TD WIDTH="33%">ISO Latin 4</TD>
097: * <TD WIDTH="15%">
098: * <P ALIGN="CENTER">ISO-8859-4
099: * </TD>
100: * <TD WIDTH="12%">
101: * <P ALIGN="CENTER">MIME
102: * </TD>
103: * <TD WIDTH="31%">
104: * <P ALIGN="CENTER">ISO-8859-4
105: * </TD>
106: * </TR>
107: * <TR>
108: * <TD WIDTH="33%">ISO Latin Cyrillic</TD>
109: * <TD WIDTH="15%">
110: * <P ALIGN="CENTER">ISO-8859-5
111: * </TD>
112: * <TD WIDTH="12%">
113: * <P ALIGN="CENTER">MIME
114: * </TD>
115: * <TD WIDTH="31%">
116: * <P ALIGN="CENTER">ISO-8859-5
117: * </TD>
118: * </TR>
119: * <TR>
120: * <TD WIDTH="33%">ISO Latin Arabic</TD>
121: * <TD WIDTH="15%">
122: * <P ALIGN="CENTER">ISO-8859-6
123: * </TD>
124: * <TD WIDTH="12%">
125: * <P ALIGN="CENTER">MIME
126: * </TD>
127: * <TD WIDTH="31%">
128: * <P ALIGN="CENTER">ISO-8859-6
129: * </TD>
130: * </TR>
131: * <TR>
132: * <TD WIDTH="33%">ISO Latin Greek</TD>
133: * <TD WIDTH="15%">
134: * <P ALIGN="CENTER">ISO-8859-7
135: * </TD>
136: * <TD WIDTH="12%">
137: * <P ALIGN="CENTER">MIME
138: * </TD>
139: * <TD WIDTH="31%">
140: * <P ALIGN="CENTER">ISO-8859-7
141: * </TD>
142: * </TR>
143: * <TR>
144: * <TD WIDTH="33%">ISO Latin Hebrew</TD>
145: * <TD WIDTH="15%">
146: * <P ALIGN="CENTER">ISO-8859-8
147: * </TD>
148: * <TD WIDTH="12%">
149: * <P ALIGN="CENTER">MIME
150: * </TD>
151: * <TD WIDTH="31%">
152: * <P ALIGN="CENTER">ISO-8859-8
153: * </TD>
154: * </TR>
155: * <TR>
156: * <TD WIDTH="33%">ISO Latin 5</TD>
157: * <TD WIDTH="15%">
158: * <P ALIGN="CENTER">ISO-8859-9
159: * </TD>
160: * <TD WIDTH="12%">
161: * <P ALIGN="CENTER">MIME
162: * </TD>
163: * <TD WIDTH="31%">
164: * <P ALIGN="CENTER">ISO-8859-9
165: * </TD>
166: * </TR>
167: * <TR>
168: * <TD WIDTH="33%">EBCDIC: US</TD>
169: * <TD WIDTH="15%">
170: * <P ALIGN="CENTER">ebcdic-cp-us
171: * </TD>
172: * <TD WIDTH="12%">
173: * <P ALIGN="CENTER">IANA
174: * </TD>
175: * <TD WIDTH="31%">
176: * <P ALIGN="CENTER">cp037
177: * </TD>
178: * </TR>
179: * <TR>
180: * <TD WIDTH="33%">EBCDIC: Canada</TD>
181: * <TD WIDTH="15%">
182: * <P ALIGN="CENTER">ebcdic-cp-ca
183: * </TD>
184: * <TD WIDTH="12%">
185: * <P ALIGN="CENTER">IANA
186: * </TD>
187: * <TD WIDTH="31%">
188: * <P ALIGN="CENTER">cp037
189: * </TD>
190: * </TR>
191: * <TR>
192: * <TD WIDTH="33%">EBCDIC: Netherlands</TD>
193: * <TD WIDTH="15%">
194: * <P ALIGN="CENTER">ebcdic-cp-nl
195: * </TD>
196: * <TD WIDTH="12%">
197: * <P ALIGN="CENTER">IANA
198: * </TD>
199: * <TD WIDTH="31%">
200: * <P ALIGN="CENTER">cp037
201: * </TD>
202: * </TR>
203: * <TR>
204: * <TD WIDTH="33%">EBCDIC: Denmark</TD>
205: * <TD WIDTH="15%">
206: * <P ALIGN="CENTER">ebcdic-cp-dk
207: * </TD>
208: * <TD WIDTH="12%">
209: * <P ALIGN="CENTER">IANA
210: * </TD>
211: * <TD WIDTH="31%">
212: * <P ALIGN="CENTER">cp277
213: * </TD>
214: * </TR>
215: * <TR>
216: * <TD WIDTH="33%">EBCDIC: Norway</TD>
217: * <TD WIDTH="15%">
218: * <P ALIGN="CENTER">ebcdic-cp-no
219: * </TD>
220: * <TD WIDTH="12%">
221: * <P ALIGN="CENTER">IANA
222: * </TD>
223: * <TD WIDTH="31%">
224: * <P ALIGN="CENTER">cp277
225: * </TD>
226: * </TR>
227: * <TR>
228: * <TD WIDTH="33%">EBCDIC: Finland</TD>
229: * <TD WIDTH="15%">
230: * <P ALIGN="CENTER">ebcdic-cp-fi
231: * </TD>
232: * <TD WIDTH="12%">
233: * <P ALIGN="CENTER">IANA
234: * </TD>
235: * <TD WIDTH="31%">
236: * <P ALIGN="CENTER">cp278
237: * </TD>
238: * </TR>
239: * <TR>
240: * <TD WIDTH="33%">EBCDIC: Sweden</TD>
241: * <TD WIDTH="15%">
242: * <P ALIGN="CENTER">ebcdic-cp-se
243: * </TD>
244: * <TD WIDTH="12%">
245: * <P ALIGN="CENTER">IANA
246: * </TD>
247: * <TD WIDTH="31%">
248: * <P ALIGN="CENTER">cp278
249: * </TD>
250: * </TR>
251: * <TR>
252: * <TD WIDTH="33%">EBCDIC: Italy</TD>
253: * <TD WIDTH="15%">
254: * <P ALIGN="CENTER">ebcdic-cp-it
255: * </TD>
256: * <TD WIDTH="12%">
257: * <P ALIGN="CENTER">IANA
258: * </TD>
259: * <TD WIDTH="31%">
260: * <P ALIGN="CENTER">cp280
261: * </TD>
262: * </TR>
263: * <TR>
264: * <TD WIDTH="33%">EBCDIC: Spain, Latin America</TD>
265: * <TD WIDTH="15%">
266: * <P ALIGN="CENTER">ebcdic-cp-es
267: * </TD>
268: * <TD WIDTH="12%">
269: * <P ALIGN="CENTER">IANA
270: * </TD>
271: * <TD WIDTH="31%">
272: * <P ALIGN="CENTER">cp284
273: * </TD>
274: * </TR>
275: * <TR>
276: * <TD WIDTH="33%">EBCDIC: Great Britain</TD>
277: * <TD WIDTH="15%">
278: * <P ALIGN="CENTER">ebcdic-cp-gb
279: * </TD>
280: * <TD WIDTH="12%">
281: * <P ALIGN="CENTER">IANA
282: * </TD>
283: * <TD WIDTH="31%">
284: * <P ALIGN="CENTER">cp285
285: * </TD>
286: * </TR>
287: * <TR>
288: * <TD WIDTH="33%">EBCDIC: France</TD>
289: * <TD WIDTH="15%">
290: * <P ALIGN="CENTER">ebcdic-cp-fr
291: * </TD>
292: * <TD WIDTH="12%">
293: * <P ALIGN="CENTER">IANA
294: * </TD>
295: * <TD WIDTH="31%">
296: * <P ALIGN="CENTER">cp297
297: * </TD>
298: * </TR>
299: * <TR>
300: * <TD WIDTH="33%">EBCDIC: Arabic</TD>
301: * <TD WIDTH="15%">
302: * <P ALIGN="CENTER">ebcdic-cp-ar1
303: * </TD>
304: * <TD WIDTH="12%">
305: * <P ALIGN="CENTER">IANA
306: * </TD>
307: * <TD WIDTH="31%">
308: * <P ALIGN="CENTER">cp420
309: * </TD>
310: * </TR>
311: * <TR>
312: * <TD WIDTH="33%">EBCDIC: Hebrew</TD>
313: * <TD WIDTH="15%">
314: * <P ALIGN="CENTER">ebcdic-cp-he
315: * </TD>
316: * <TD WIDTH="12%">
317: * <P ALIGN="CENTER">IANA
318: * </TD>
319: * <TD WIDTH="31%">
320: * <P ALIGN="CENTER">cp424
321: * </TD>
322: * </TR>
323: * <TR>
324: * <TD WIDTH="33%">EBCDIC: Switzerland</TD>
325: * <TD WIDTH="15%">
326: * <P ALIGN="CENTER">ebcdic-cp-ch
327: * </TD>
328: * <TD WIDTH="12%">
329: * <P ALIGN="CENTER">IANA
330: * </TD>
331: * <TD WIDTH="31%">
332: * <P ALIGN="CENTER">cp500
333: * </TD>
334: * </TR>
335: * <TR>
336: * <TD WIDTH="33%">EBCDIC: Roece</TD>
337: * <TD WIDTH="15%">
338: * <P ALIGN="CENTER">ebcdic-cp-roece
339: * </TD>
340: * <TD WIDTH="12%">
341: * <P ALIGN="CENTER">IANA
342: * </TD>
343: * <TD WIDTH="31%">
344: * <P ALIGN="CENTER">cp870
345: * </TD>
346: * </TR>
347: * <TR>
348: * <TD WIDTH="33%">EBCDIC: Yogoslavia</TD>
349: * <TD WIDTH="15%">
350: * <P ALIGN="CENTER">ebcdic-cp-yu
351: * </TD>
352: * <TD WIDTH="12%">
353: * <P ALIGN="CENTER">IANA
354: * </TD>
355: * <TD WIDTH="31%">
356: * <P ALIGN="CENTER">cp870
357: * </TD>
358: * </TR>
359: * <TR>
360: * <TD WIDTH="33%">EBCDIC: Iceland</TD>
361: * <TD WIDTH="15%">
362: * <P ALIGN="CENTER">ebcdic-cp-is
363: * </TD>
364: * <TD WIDTH="12%">
365: * <P ALIGN="CENTER">IANA
366: * </TD>
367: * <TD WIDTH="31%">
368: * <P ALIGN="CENTER">cp871
369: * </TD>
370: * </TR>
371: * <TR>
372: * <TD WIDTH="33%">EBCDIC: Urdu</TD>
373: * <TD WIDTH="15%">
374: * <P ALIGN="CENTER">ebcdic-cp-ar2
375: * </TD>
376: * <TD WIDTH="12%">
377: * <P ALIGN="CENTER">IANA
378: * </TD>
379: * <TD WIDTH="31%">
380: * <P ALIGN="CENTER">cp918
381: * </TD>
382: * </TR>
383: * <TR>
384: * <TD WIDTH="33%">Chinese for PRC, mixed 1/2 byte</TD>
385: * <TD WIDTH="15%">
386: * <P ALIGN="CENTER">gb2312
387: * </TD>
388: * <TD WIDTH="12%">
389: * <P ALIGN="CENTER">MIME
390: * </TD>
391: * <TD WIDTH="31%">
392: * <P ALIGN="CENTER">GB2312
393: * </TD>
394: * </TR>
395: * <TR>
396: * <TD WIDTH="33%">Extended Unix Code, packed for Japanese</TD>
397: * <TD WIDTH="15%">
398: * <P ALIGN="CENTER">euc-jp
399: * </TD>
400: * <TD WIDTH="12%">
401: * <P ALIGN="CENTER">MIME
402: * </TD>
403: * <TD WIDTH="31%">
404: * <P ALIGN="CENTER">eucjis
405: * </TD>
406: * </TR>
407: * <TR>
408: * <TD WIDTH="33%">Japanese: iso-2022-jp</TD>
409: * <TD WIDTH="15%">
410: * <P ALIGN="CENTER">iso-2020-jp
411: * </TD>
412: * <TD WIDTH="12%">
413: * <P ALIGN="CENTER">MIME
414: * </TD>
415: * <TD WIDTH="31%">
416: * <P ALIGN="CENTER">JIS
417: * </TD>
418: * </TR>
419: * <TR>
420: * <TD WIDTH="33%">Japanese: Shift JIS</TD>
421: * <TD WIDTH="15%">
422: * <P ALIGN="CENTER">Shift_JIS
423: * </TD>
424: * <TD WIDTH="12%">
425: * <P ALIGN="CENTER">MIME
426: * </TD>
427: * <TD WIDTH="31%">
428: * <P ALIGN="CENTER">SJIS
429: * </TD>
430: * </TR>
431: * <TR>
432: * <TD WIDTH="33%">Chinese: Big5</TD>
433: * <TD WIDTH="15%">
434: * <P ALIGN="CENTER">Big5
435: * </TD>
436: * <TD WIDTH="12%">
437: * <P ALIGN="CENTER">MIME
438: * </TD>
439: * <TD WIDTH="31%">
440: * <P ALIGN="CENTER">Big5
441: * </TD>
442: * </TR>
443: * <TR>
444: * <TD WIDTH="33%">Extended Unix Code, packed for Korean</TD>
445: * <TD WIDTH="15%">
446: * <P ALIGN="CENTER">euc-kr
447: * </TD>
448: * <TD WIDTH="12%">
449: * <P ALIGN="CENTER">MIME
450: * </TD>
451: * <TD WIDTH="31%">
452: * <P ALIGN="CENTER">iso2022kr
453: * </TD>
454: * </TR>
455: * <TR>
456: * <TD WIDTH="33%">Cyrillic</TD>
457: * <TD WIDTH="15%">
458: * <P ALIGN="CENTER">koi8-r
459: * </TD>
460: * <TD WIDTH="12%">
461: * <P ALIGN="CENTER">MIME
462: * </TD>
463: * <TD WIDTH="31%">
464: * <P ALIGN="CENTER">koi8-r
465: * </TD>
466: * </TR>
467: * </TABLE>
468: *
469: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
470: * @author TAMURA Kent <kent@trl.ibm.co.jp>
471: */
472: public class MIME2Java {
473:
474: static private Hashtable s_enchash;
475: static private Hashtable s_revhash;
476:
477: static {
478: s_enchash = new Hashtable();
479: // <preferred MIME name>, <Java encoding name>
480: s_enchash.put("UTF-8", "UTF8");
481: s_enchash.put("US-ASCII", "8859_1"); // ?
482: s_enchash.put("ISO-8859-1", "8859_1");
483: s_enchash.put("ISO-8859-2", "8859_2");
484: s_enchash.put("ISO-8859-3", "8859_3");
485: s_enchash.put("ISO-8859-4", "8859_4");
486: s_enchash.put("ISO-8859-5", "8859_5");
487: s_enchash.put("ISO-8859-6", "8859_6");
488: s_enchash.put("ISO-8859-7", "8859_7");
489: s_enchash.put("ISO-8859-8", "8859_8");
490: s_enchash.put("ISO-8859-9", "8859_9");
491: s_enchash.put("ISO-2022-JP", "JIS");
492: s_enchash.put("SHIFT_JIS", "SJIS");
493: s_enchash.put("EUC-JP", "EUCJIS");
494: s_enchash.put("GB2312", "GB2312");
495: s_enchash.put("BIG5", "Big5");
496: s_enchash.put("EUC-KR", "KSC5601");
497: s_enchash.put("ISO-2022-KR", "ISO2022KR");
498: s_enchash.put("KOI8-R", "KOI8_R");
499:
500: s_enchash.put("EBCDIC-CP-US", "CP037");
501: s_enchash.put("EBCDIC-CP-CA", "CP037");
502: s_enchash.put("EBCDIC-CP-NL", "CP037");
503: s_enchash.put("EBCDIC-CP-DK", "CP277");
504: s_enchash.put("EBCDIC-CP-NO", "CP277");
505: s_enchash.put("EBCDIC-CP-FI", "CP278");
506: s_enchash.put("EBCDIC-CP-SE", "CP278");
507: s_enchash.put("EBCDIC-CP-IT", "CP280");
508: s_enchash.put("EBCDIC-CP-ES", "CP284");
509: s_enchash.put("EBCDIC-CP-GB", "CP285");
510: s_enchash.put("EBCDIC-CP-FR", "CP297");
511: s_enchash.put("EBCDIC-CP-AR1", "CP420");
512: s_enchash.put("EBCDIC-CP-HE", "CP424");
513: s_enchash.put("EBCDIC-CP-CH", "CP500");
514: s_enchash.put("EBCDIC-CP-ROECE", "CP870");
515: s_enchash.put("EBCDIC-CP-YU", "CP870");
516: s_enchash.put("EBCDIC-CP-IS", "CP871");
517: s_enchash.put("EBCDIC-CP-AR2", "CP918");
518:
519: // j:CNS11643 -> EUC-TW?
520: // ISO-2022-CN? ISO-2022-CN-EXT?
521:
522: s_revhash = new Hashtable();
523: // <Java encoding name>, <preferred MIME name>
524: s_revhash.put("UTF8", "UTF-8");
525: //s_revhash.put("8859_1", "US-ASCII"); // ?
526: s_revhash.put("8859_1", "ISO-8859-1");
527: s_revhash.put("8859_2", "ISO-8859-2");
528: s_revhash.put("8859_3", "ISO-8859-3");
529: s_revhash.put("8859_4", "ISO-8859-4");
530: s_revhash.put("8859_5", "ISO-8859-5");
531: s_revhash.put("8859_6", "ISO-8859-6");
532: s_revhash.put("8859_7", "ISO-8859-7");
533: s_revhash.put("8859_8", "ISO-8859-8");
534: s_revhash.put("8859_9", "ISO-8859-9");
535: s_revhash.put("JIS", "ISO-2022-JP");
536: s_revhash.put("SJIS", "Shift_JIS");
537: s_revhash.put("EUCJIS", "EUC-JP");
538: s_revhash.put("GB2312", "GB2312");
539: s_revhash.put("BIG5", "Big5");
540: s_revhash.put("KSC5601", "EUC-KR");
541: s_revhash.put("ISO2022KR", "ISO-2022-KR");
542: s_revhash.put("KOI8_R", "KOI8-R");
543:
544: s_revhash.put("CP037", "EBCDIC-CP-US");
545: s_revhash.put("CP037", "EBCDIC-CP-CA");
546: s_revhash.put("CP037", "EBCDIC-CP-NL");
547: s_revhash.put("CP277", "EBCDIC-CP-DK");
548: s_revhash.put("CP277", "EBCDIC-CP-NO");
549: s_revhash.put("CP278", "EBCDIC-CP-FI");
550: s_revhash.put("CP278", "EBCDIC-CP-SE");
551: s_revhash.put("CP280", "EBCDIC-CP-IT");
552: s_revhash.put("CP284", "EBCDIC-CP-ES");
553: s_revhash.put("CP285", "EBCDIC-CP-GB");
554: s_revhash.put("CP297", "EBCDIC-CP-FR");
555: s_revhash.put("CP420", "EBCDIC-CP-AR1");
556: s_revhash.put("CP424", "EBCDIC-CP-HE");
557: s_revhash.put("CP500", "EBCDIC-CP-CH");
558: s_revhash.put("CP870", "EBCDIC-CP-ROECE");
559: s_revhash.put("CP870", "EBCDIC-CP-YU");
560: s_revhash.put("CP871", "EBCDIC-CP-IS");
561: s_revhash.put("CP918", "EBCDIC-CP-AR2");
562: }
563:
564: private MIME2Java() {
565: }
566:
567: /**
568: * Convert a MIME charset name, also known as an XML encoding name, to a Java encoding name.
569: * @param mimeCharsetName Case insensitive MIME charset name: <code>UTF-8, US-ASCII, ISO-8859-1,
570: * ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6,
571: * ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-2022-JP, Shift_JIS,
572: * EUC-JP, GB2312, Big5, EUC-KR, ISO-2022-KR, KOI8-R,
573: * EBCDIC-CP-US, EBCDIC-CP-CA, EBCDIC-CP-NL, EBCDIC-CP-DK,
574: * EBCDIC-CP-NO, EBCDIC-CP-FI, EBCDIC-CP-SE, EBCDIC-CP-IT,
575: * EBCDIC-CP-ES, EBCDIC-CP-GB, EBCDIC-CP-FR, EBCDIC-CP-AR1,
576: * EBCDIC-CP-HE, EBCDIC-CP-CH, EBCDIC-CP-ROECE, EBCDIC-CP-YU,
577: * EBCDIC-CP-IS and EBCDIC-CP-AR2</code>.
578: * @return Java encoding name, or <var>null</var> if <var>mimeCharsetName</var>
579: * is unknown.
580: * @see #reverse
581: */
582: public static String convert(String mimeCharsetName) {
583: return (String) s_enchash.get(mimeCharsetName.toUpperCase());
584: }
585:
586: /**
587: * Convert a Java encoding name to MIME charset name.
588: * Available values of <i>encoding</i> are "UTF8", "8859_1", "8859_2", "8859_3", "8859_4",
589: * "8859_5", "8859_6", "8859_7", "8859_8", "8859_9", "JIS", "SJIS", "EUCJIS",
590: * "GB2312", "BIG5", "KSC5601", "ISO2022KR", "KOI8_R", "CP037", "CP277", "CP278",
591: * "CP280", "CP284", "CP285", "CP297", "CP420", "CP424", "CP500", "CP870", "CP871" and "CP918".
592: * @param encoding Case insensitive Java encoding name: <code>UTF8, 8859_1, 8859_2, 8859_3,
593: * 8859_4, 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
596: * and CP918</code>.
597: * @return MIME charset name, or <var>null</var> if <var>encoding</var> is unknown.
598: * @see #convert
599: */
600: public static String reverse(String encoding) {
601: return (String) s_revhash.get(encoding.toUpperCase());
602: }
603: }
|