@Test public void testGetCharset() throws Exception { assertEquals(Charset.forName("IBM500"), getCharset(500, UNUSED)); assertEquals(Charset.forName("IBM850"), getCharset(850, UNUSED)); assertEquals(Charset.forName("UTF-16"), getCharset(1200, UNUSED)); assertEquals(Charset.forName("windows-1252"), getCharset(1252, UNUSED)); assertEquals(Charset.forName("IBM01141"), getCharset(1141, UNUSED)); assertEquals(Charset.forName("IBM273"), getCharset(273, UNUSED)); assertEquals(Charset.forName("IBM500"), getCharset(9999999, UNUSED)); }
public static Charset getCharset(int cpgid, int gcsgid) { Charset result; if(cpgid == 1200) { result = Charset.forName("UTF-16"); } else if(cpgid == 1252) { result = Charset.forName("windows-1252"); } else { try { result = Charset.forName("cp"+cpgid); } catch (UnsupportedCharsetException e) { log.error("unknown gpgid {}", cpgid); result = CHARSET_IBM500; } } return result; }
CodepageHelper { public static Charset getCharset(int cpgid, int gcsgid) { Charset result; if(cpgid == 1200) { result = Charset.forName("UTF-16"); } else if(cpgid == 1252) { result = Charset.forName("windows-1252"); } else { try { result = Charset.forName("cp"+cpgid); } catch (UnsupportedCharsetException e) { log.error("unknown gpgid {}", cpgid); result = CHARSET_IBM500; } } return result; } }
CodepageHelper { public static Charset getCharset(int cpgid, int gcsgid) { Charset result; if(cpgid == 1200) { result = Charset.forName("UTF-16"); } else if(cpgid == 1252) { result = Charset.forName("windows-1252"); } else { try { result = Charset.forName("cp"+cpgid); } catch (UnsupportedCharsetException e) { log.error("unknown gpgid {}", cpgid); result = CHARSET_IBM500; } } return result; }  }
CodepageHelper { public static Charset getCharset(int cpgid, int gcsgid) { Charset result; if(cpgid == 1200) { result = Charset.forName("UTF-16"); } else if(cpgid == 1252) { result = Charset.forName("windows-1252"); } else { try { result = Charset.forName("cp"+cpgid); } catch (UnsupportedCharsetException e) { log.error("unknown gpgid {}", cpgid); result = CHARSET_IBM500; } } return result; }  static Charset getCharset(int cpgid, int gcsgid); }
CodepageHelper { public static Charset getCharset(int cpgid, int gcsgid) { Charset result; if(cpgid == 1200) { result = Charset.forName("UTF-16"); } else if(cpgid == 1252) { result = Charset.forName("windows-1252"); } else { try { result = Charset.forName("cp"+cpgid); } catch (UnsupportedCharsetException e) { log.error("unknown gpgid {}", cpgid); result = CHARSET_IBM500; } } return result; }  static Charset getCharset(int cpgid, int gcsgid); static final Charset CHARSET_IBM500; }