static private String determineMailHeaderEncodingCharset(String rawText){
  if (rawText == null)   return null;
  int iEncodingPrefix=rawText.indexOf("=?");
  if (iEncodingPrefix == -1)   return null;
  int iCharsetBegin=iEncodingPrefix + 2;
  int iSecondQuestionMark=rawText.indexOf('?',iCharsetBegin);
  if (iSecondQuestionMark == -1)   return null;
  if (iSecondQuestionMark == iCharsetBegin)   return null;
  int iThirdQuestionMark=rawText.indexOf('?',iSecondQuestionMark + 1);
  if (iThirdQuestionMark == -1)   return null;
  if (-1 == rawText.indexOf("?=",iThirdQuestionMark + 1))   return null;
  return rawText.substring(iCharsetBegin,iSecondQuestionMark);
}

static private String determineMailHeaderEncodingCharset ( String rawText ) { if ( rawText == null ) return null ; int iEncodingPrefix = rawText . indexOf ( "=?" ) ; if ( iEncodingPrefix == - 1 ) return null ; int iCharsetBegin = iEncodingPrefix + 2 ; int iSecondQuestionMark = rawText . indexOf ( '?' , iCharsetBegin ) ; if ( iSecondQuestionMark == - 1 ) return null ; if ( iSecondQuestionMark == iCharsetBegin ) return null ; int iThirdQuestionMark = rawText . indexOf ( '?' , iSecondQuestionMark + 1 ) ; if ( iThirdQuestionMark == - 1 ) return null ; if ( - 1 == rawText . indexOf ( "?=" , iThirdQuestionMark + 1 ) ) return null ; return rawText . substring ( iCharsetBegin , iSecondQuestionMark ) ; }
it attempts to determine the charset used to encode an " unstructured " rfc 822 header ( like subject ) . the encoding is specified in rfc 2047 . if it cannot determine or the the text is not encoded then it returns null . < p / > here is an example raw text : subject : = ? iso - 8859 - 2 ? q ? leg = fajabb_pr = f3ba_l = f5elemmel ? =
