1 17 18 package org.apache.catalina.util; 19 20 import java.util.*; 21 22 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 s_enchash.put("UTF-8", "UTF8"); 481 s_enchash.put("US-ASCII", "8859_1"); 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 522 s_revhash = new Hashtable(); 523 s_revhash.put("UTF8", "UTF-8"); 525 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 582 public static String convert(String mimeCharsetName) { 583 return (String )s_enchash.get(mimeCharsetName.toUpperCase()); 584 } 585 586 600 public static String reverse(String encoding) { 601 return (String )s_revhash.get(encoding.toUpperCase()); 602 } 603 } 604 | Popular Tags |