List of utility methods to do Charset Guess
String | getCharset(File file) get Charset String code = "GBK"; FileInputStream fis = null; try { byte[] head = new byte[3]; fis = new FileInputStream(file); fis.read(head); code = getCharset(head); } catch (Exception e) { ... |
String | getCharset(Object resource) get Charset if (resource instanceof InputStreamReader) { return ((InputStreamReader) resource).getEncoding(); return null; |
Writer | getCharsetFileWriter(File file, String charset) get Charset File Writer return new OutputStreamWriter(new FileOutputStream(file), charset); |
String | getCharsetFromBytes(byte abyte0[]) get Charset From Bytes if (abyte0 == null) return null; String s = null; try { s = new String(abyte0, "ISO-8859-1"); } catch (UnsupportedEncodingException unsupportedencodingexception) { if (s == null) { ... |
String | getCharSetStr(String str, String oldCharSet, String newCharSet) get Char Set Str if (str == "" || str == null) { return ""; try { str = new String(str.getBytes(oldCharSet), newCharSet); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return str; |
char | getPYIndexChar(char strChinese, boolean bUpCase) get PY Index Char int charGBK = strChinese; char result; if (charGBK >= 45217 && charGBK <= 45252) result = 'A'; else if (charGBK >= 45253 && charGBK <= 45760) result = 'B'; else if (charGBK >= 45761 && charGBK <= 46317 || charGBK == 55000) result = 'C'; ... |