1 57 58 package org.enhydra.apache.xerces.readers; 59 60 import java.util.Hashtable ; 61 62 524 public class MIME2Java { 525 526 static private Hashtable s_enchash; 527 static private Hashtable s_revhash; 528 529 static { 530 s_enchash = new Hashtable (); 531 s_enchash.put("UTF-8", "UTF8"); 533 s_enchash.put("US-ASCII", "ASCII"); 534 s_enchash.put("ISO-IR-6", "ASCII"); 535 s_enchash.put("ANSI_X3.4-1986", "ASCII"); 536 s_enchash.put("ISO_646.IRV:1991", "ASCII"); 537 s_enchash.put("ASCII", "ASCII"); 538 s_enchash.put("ISO646-US", "ASCII"); 539 s_enchash.put("US", "ASCII"); 540 s_enchash.put("IBM367", "ASCII"); 541 s_enchash.put("CP367", "ASCII"); 542 s_enchash.put("ISO-8859-1", "ISO8859_1"); 543 s_enchash.put("ISO-IR-100", "ISO8859_1"); 544 s_enchash.put("ISO_8859-1", "ISO8859_1"); 545 s_enchash.put("LATIN1", "ISO8859_1"); 546 s_enchash.put("L1", "ISO8859_1"); 547 s_enchash.put("IBM819", "ISO8859_1"); 548 s_enchash.put("CP819", "ISO8859_1"); 549 s_enchash.put("ISO-8859-2", "ISO8859_2"); 550 s_enchash.put("ISO-IR-101", "ISO8859_2"); 551 s_enchash.put("ISO_8859-2", "ISO8859_2"); 552 s_enchash.put("LATIN2", "ISO8859_2"); 553 s_enchash.put("L2", "ISO8859_2"); 554 s_enchash.put("ISO-8859-3", "ISO8859_3"); 555 s_enchash.put("ISO-IR-109", "ISO8859_3"); 556 s_enchash.put("ISO_8859-3", "ISO8859_3"); 557 s_enchash.put("LATIN3", "ISO8859_3"); 558 s_enchash.put("L3", "ISO8859_3"); 559 s_enchash.put("ISO-8859-4", "ISO8859_4"); 560 s_enchash.put("ISO-IR-110", "ISO8859_4"); 561 s_enchash.put("ISO_8859-4", "ISO8859_4"); 562 s_enchash.put("LATIN4", "ISO8859_4"); 563 s_enchash.put("L4", "ISO8859_4"); 564 s_enchash.put("ISO-8859-5", "ISO8859_5"); 565 s_enchash.put("ISO-IR-144", "ISO8859_5"); 566 s_enchash.put("ISO_8859-5", "ISO8859_5"); 567 s_enchash.put("CYRILLIC", "ISO8859_5"); 568 s_enchash.put("ISO-8859-6", "ISO8859_6"); 569 s_enchash.put("ISO-IR-127", "ISO8859_6"); 570 s_enchash.put("ISO_8859-6", "ISO8859_6"); 571 s_enchash.put("ECMA-114", "ISO8859_6"); 572 s_enchash.put("ASMO-708", "ISO8859_6"); 573 s_enchash.put("ARABIC", "ISO8859_6"); 574 s_enchash.put("ISO-8859-7", "ISO8859_7"); 575 s_enchash.put("ISO-IR-126", "ISO8859_7"); 576 s_enchash.put("ISO_8859-7", "ISO8859_7"); 577 s_enchash.put("ELOT_928", "ISO8859_7"); 578 s_enchash.put("ECMA-118", "ISO8859_7"); 579 s_enchash.put("GREEK", "ISO8859_7"); 580 s_enchash.put("GREEK8", "ISO8859_7"); 581 s_enchash.put("ISO-8859-8", "ISO8859_8"); 582 s_enchash.put("ISO-IR-138", "ISO8859_8"); 583 s_enchash.put("ISO_8859-8", "ISO8859_8"); 584 s_enchash.put("HEBREW", "ISO8859_8"); 585 s_enchash.put("ISO-8859-9", "ISO8859_9"); 586 s_enchash.put("ISO-IR-148", "ISO8859_9"); 587 s_enchash.put("ISO_8859-9", "ISO8859_9"); 588 s_enchash.put("LATIN5", "ISO8859_9"); 589 s_enchash.put("L5", "ISO8859_9"); 590 s_enchash.put("ISO-2022-JP", "ISO2022JP"); 591 s_enchash.put("SHIFT_JIS", "SJIS"); 592 s_enchash.put("MS_Kanji", "SJIS"); 593 597 String version = System.getProperty("java.version"); 598 if (version.equals("1.1") || version.startsWith("1.1.")) { 599 s_enchash.put("WINDOWS-31J", "SJIS"); 600 } else { 601 s_enchash.put("WINDOWS-31J", "MS932"); 602 } 603 s_enchash.put("EUC-JP", "EUC_JP"); 604 s_enchash.put("GB2312", "GB2312"); 605 s_enchash.put("BIG5", "Big5"); 606 s_enchash.put("EUC-KR", "EUC_KR"); 607 s_enchash.put("ISO-2022-KR", "ISO2022KR"); 608 s_enchash.put("KOI8-R", "KOI8_R"); 609 s_enchash.put("ISO8859_1", "8859_1"); 610 611 s_enchash.put("EBCDIC-CP-US", "CP037"); 612 s_enchash.put("EBCDIC-CP-CA", "CP037"); 613 s_enchash.put("EBCDIC-CP-NL", "CP037"); 614 s_enchash.put("EBCDIC-CP-WT", "CP037"); 615 s_enchash.put("EBCDIC-CP-DK", "CP277"); 616 s_enchash.put("EBCDIC-CP-NO", "CP277"); 617 s_enchash.put("EBCDIC-CP-FI", "CP278"); 618 s_enchash.put("EBCDIC-CP-SE", "CP278"); 619 s_enchash.put("EBCDIC-CP-IT", "CP280"); 620 s_enchash.put("EBCDIC-CP-ES", "CP284"); 621 s_enchash.put("EBCDIC-CP-GB", "CP285"); 622 s_enchash.put("EBCDIC-CP-FR", "CP297"); 623 s_enchash.put("EBCDIC-CP-AR1", "CP420"); 624 s_enchash.put("EBCDIC-CP-HE", "CP424"); 625 s_enchash.put("EBCDIC-CP-CH", "CP500"); 626 s_enchash.put("EBCDIC-CP-BE", "CP500"); 627 s_enchash.put("CP-AR", "CP868"); 628 s_enchash.put("CP-GR", "CP869"); 629 s_enchash.put("EBCDIC-CP-ROECE", "CP870"); 630 s_enchash.put("EBCDIC-CP-YU", "CP870"); 631 s_enchash.put("EBCDIC-CP-IS", "CP871"); 632 s_enchash.put("EBCDIC-CP-AR2", "CP918"); 633 634 s_enchash.put("WINDOWS-1250", "Cp1250"); 636 s_enchash.put("WINDOWS-1251", "Cp1251"); 637 s_enchash.put("WINDOWS-1252", "Cp1252"); 638 s_enchash.put("WINDOWS-1253", "Cp1253"); 639 s_enchash.put("WINDOWS-1254", "Cp1254"); 640 s_enchash.put("WINDOWS-1255", "Cp1255"); 641 s_enchash.put("WINDOWS-1256", "Cp1256"); 642 s_enchash.put("WINDOWS-1257", "Cp1257"); 643 s_enchash.put("WINDOWS-1258", "Cp1258"); 644 s_enchash.put("TIS-620", "TIS620"); 645 s_enchash.put("ISO-2022-CN", "ISO2022CN"); 647 s_enchash.put("X0201", "JIS0201"); 648 s_enchash.put("X0208", "JIS0208"); 649 s_enchash.put("X0212", "JIS0212"); 650 s_enchash.put("ISO-IR-159", "JIS0212"); 651 652 s_revhash = new Hashtable (); 653 s_revhash.put("UTF8", "UTF-8"); 655 s_revhash.put("ASCII", "US-ASCII"); 656 s_revhash.put("ASCII", "ISO-IR-6"); 657 s_revhash.put("ASCII", "ANSI_X3.4-1986"); 658 s_revhash.put("ASCII", "ISO_646.IRV:1991"); 659 s_revhash.put("ASCII", "ASCII"); 660 s_revhash.put("ASCII", "ISO646-US"); 661 s_revhash.put("ASCII", "US"); 662 s_revhash.put("ASCII", "IBM367"); 663 s_revhash.put("ASCII", "CP367"); 664 s_revhash.put("ISO8859_1", "ISO-8859-1"); 665 s_revhash.put("ISO8859_1", "ISO-IR-100"); 666 s_revhash.put("ISO8859_1", "ISO_8859-1"); 667 s_revhash.put("ISO8859_1", "LATIN1"); 668 s_revhash.put("ISO8859_1", "L1"); 669 s_revhash.put("ISO8859_1", "IBM819"); 670 s_revhash.put("ISO8859_1", "CP819"); 671 s_revhash.put("ISO8859_2", "ISO-8859-2"); 672 s_revhash.put("ISO8859_2", "ISO-IR-101"); 673 s_revhash.put("ISO8859_2", "ISO_8859-2"); 674 s_revhash.put("ISO8859_2", "LATIN2"); 675 s_revhash.put("ISO8859_2", "L2"); 676 s_revhash.put("ISO8859_3", "ISO-8859-3"); 677 s_revhash.put("ISO8859_3", "ISO-IR-109"); 678 s_revhash.put("ISO8859_3", "ISO_8859-3"); 679 s_revhash.put("ISO8859_3", "LATIN3"); 680 s_revhash.put("ISO8859_3", "L3"); 681 s_revhash.put("ISO8859_4", "ISO-8859-4"); 682 s_revhash.put("ISO8859_4", "ISO-IR-110"); 683 s_revhash.put("ISO8859_4", "ISO_8859-4"); 684 s_revhash.put("ISO8859_4", "LATIN4"); 685 s_revhash.put("ISO8859_4", "L4"); 686 s_revhash.put("ISO8859_5", "ISO-8859-5"); 687 s_revhash.put("ISO8859_5", "ISO-IR-144"); 688 s_revhash.put("ISO8859_5", "ISO_8859-5"); 689 s_revhash.put("ISO8859_5", "CYRILLIC"); 690 s_revhash.put("ISO8859_6", "ISO-8859-6"); 691 s_revhash.put("ISO8859_6", "ISO-IR-127"); 692 s_revhash.put("ISO8859_6", "ISO_8859-6"); 693 s_revhash.put("ISO8859_6", "ECMA-114"); 694 s_revhash.put("ISO8859_6", "ASMO-708"); 695 s_revhash.put("ISO8859_6", "ARABIC"); 696 s_revhash.put("ISO8859_7", "ISO-8859-7"); 697 s_revhash.put("ISO8859_7", "ISO-IR-126"); 698 s_revhash.put("ISO8859_7", "ISO_8859-7"); 699 s_revhash.put("ISO8859_7", "ELOT_928"); 700 s_revhash.put("ISO8859_7", "ECMA-118"); 701 s_revhash.put("ISO8859_7", "GREEK"); 702 s_revhash.put("ISO8859_7", "GREEK8"); 703 s_revhash.put("ISO8859_8", "ISO-8859-8"); 704 s_revhash.put("ISO8859_8", "ISO-IR-138"); 705 s_revhash.put("ISO8859_8", "ISO_8859-8"); 706 s_revhash.put("ISO8859_8", "HEBREW"); 707 s_revhash.put("ISO8859_9", "ISO-8859-9"); 708 s_revhash.put("ISO8859_9", "ISO-IR-148"); 709 s_revhash.put("ISO8859_9", "ISO_8859-9"); 710 s_revhash.put("ISO8859_9", "LATIN5"); 711 s_revhash.put("ISO8859_9", "L5"); 712 s_revhash.put("ISO2022JP", "ISO-2022-JP"); 713 s_revhash.put("SJIS", "Shift_JIS"); 714 s_revhash.put("SJIS", "MS_Kanji"); 715 s_revhash.put("MS932", "WINDOWS-31J"); 716 s_revhash.put("EUC_JP", "EUC-JP"); 717 s_revhash.put("GB2312", "GB2312"); 718 s_revhash.put("BIG5", "Big5"); 719 s_revhash.put("EUC_KR", "EUC-KR"); 720 s_revhash.put("ISO2022KR", "ISO-2022-KR"); 721 s_revhash.put("KOI8_R", "KOI8-R"); 722 723 s_revhash.put("CP037", "EBCDIC-CP-US"); 724 s_revhash.put("CP037", "EBCDIC-CP-CA"); 725 s_revhash.put("CP037", "EBCDIC-CP-NL"); 726 s_revhash.put("CP037", "EBCDIC-CP-WT"); 727 s_revhash.put("CP277", "EBCDIC-CP-DK"); 728 s_revhash.put("CP277", "EBCDIC-CP-NO"); 729 s_revhash.put("CP278", "EBCDIC-CP-FI"); 730 s_revhash.put("CP278", "EBCDIC-CP-SE"); 731 s_revhash.put("CP280", "EBCDIC-CP-IT"); 732 s_revhash.put("CP284", "EBCDIC-CP-ES"); 733 s_revhash.put("CP285", "EBCDIC-CP-GB"); 734 s_revhash.put("CP297", "EBCDIC-CP-FR"); 735 s_revhash.put("CP420", "EBCDIC-CP-AR1"); 736 s_revhash.put("CP424", "EBCDIC-CP-HE"); 737 s_revhash.put("CP500", "EBCDIC-CP-CH"); 738 s_revhash.put("CP500", "EBCDIC-CP-BE"); 739 s_revhash.put("CP868", "CP-AR"); 740 s_revhash.put("CP869", "CP-GR"); 741 s_revhash.put("CP870", "EBCDIC-CP-ROECE"); 742 s_revhash.put("CP870", "EBCDIC-CP-YU"); 743 s_revhash.put("CP871", "EBCDIC-CP-IS"); 744 s_revhash.put("CP918", "EBCDIC-CP-AR2"); 745 746 s_revhash.put("CP1250", "WINDOWS-1250"); 750 s_revhash.put("CP1251", "WINDOWS-1251"); 751 s_revhash.put("CP1252", "WINDOWS-1252"); 752 s_revhash.put("CP1253", "WINDOWS-1253"); 753 s_revhash.put("CP1254", "WINDOWS-1254"); 754 s_revhash.put("CP1255", "WINDOWS-1255"); 755 s_revhash.put("CP1256", "WINDOWS-1256"); 756 s_revhash.put("CP1257", "WINDOWS-1257"); 757 s_revhash.put("CP1258", "WINDOWS-1258"); 758 s_revhash.put("TIS620", "TIS-620"); 759 s_revhash.put("ISO2022CN", "ISO-2022-CN"); 760 s_revhash.put("JIS0201", "X0201"); 761 s_revhash.put("JIS0208", "X0208"); 762 s_revhash.put("JIS0212", "X0212"); 763 s_revhash.put("JIS0212", "ISO-IR-159"); 764 } 765 766 private MIME2Java() { 767 } 768 769 784 public static String convert(String mimeCharsetName) { 785 return (String )s_enchash.get(mimeCharsetName.toUpperCase()); 786 } 787 788 802 public static String reverse(String encoding) { 803 return (String )s_revhash.get(encoding.toUpperCase()); 804 } 805 } 806 | Popular Tags |