1 package SnowMailClient.utils; 2 3 import SnowMailClient.model.*; 4 import java.util.*; 5 import java.text.*; 6 import java.io.*; 7 8 public final class HeaderUtils 9 { 10 11 private HeaderUtils() 12 { 13 } 14 15 18 public static String getHeader_Charset_entry(Header header) throws Exception 19 { 20 String ct = header.getEntryValue("Content-Type", "").toUpperCase(); 21 int pos = ct.indexOf("CHARSET="); 22 if(pos>=0) 23 { 24 String cs = ct.substring(pos+8).trim(); 25 26 if(cs.startsWith("\"")) cs = cs.substring(1); 28 29 pos = cs.indexOf(";"); 31 if(pos>0) cs = cs.substring(0,pos); 32 33 if(cs.endsWith("\"")) cs = cs.substring(0,cs.length()-1); 35 return cs; 36 } 37 return "iso-8859-1"; 38 } 39 40 41 } | Popular Tags |