1 8 9 package org.jboss.util.xml; 10 11 import java.util.*; 12 13 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 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 501 String 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 536 s_revhash = new Hashtable(); 537 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 597 public static String convert(String mimeCharsetName) { 598 return (String )s_enchash.get(mimeCharsetName.toUpperCase()); 599 } 600 601 615 public static String reverse(String encoding) { 616 return (String )s_revhash.get(encoding.toUpperCase()); 617 } 618 } 619 | Popular Tags |