public String encoding(){
  if (_readEncoding != null)   return _readEncoding;
  CharSegment value=getHeaderBuffer("Content-Type");
  if (value == null)   return null;
  int i=value.indexOf("charset");
  if (i < 0)   return null;
  int len=value.length();
  for (i+=7; i < len && Character.isWhitespace(value.charAt(i)); i++) {
  }
  if (i >= len || value.charAt(i) != '=')   return null;
  for (i++; i < len && Character.isWhitespace(value.charAt(i)); i++) {
  }
  if (i >= len)   return null;
  char end=value.charAt(i);
  if (end == '"') {
    int tail;
    for (tail=++i; tail < len; tail++) {
      if (value.charAt(tail) == end)       break;
    }
    _readEncoding=Encoding.getMimeName(value.substring(i,tail));
    return _readEncoding;
  }
  int tail;
  for (tail=i; tail < len; tail++) {
    if (Character.isWhitespace(value.charAt(tail)) || value.charAt(tail) == ';')     break;
  }
  _readEncoding=Encoding.getMimeName(value.substring(i,tail));
  return _readEncoding;
}

public String encoding ( ) { if ( _readEncoding != null ) return _readEncoding ; CharSegment value = getHeaderBuffer ( "Content-Type" ) ; if ( value == null ) return null ; int i = value . indexOf ( "charset" ) ; if ( i < 0 ) return null ; int len = value . length ( ) ; for ( i += 7 ; i < len && Character . isWhitespace ( value . charAt ( i ) ) ; i ++ ) { } if ( i >= len || value . charAt ( i ) != '=' ) return null ; for ( i ++ ; i < len && Character . isWhitespace ( value . charAt ( i ) ) ; i ++ ) { } if ( i >= len ) return null ; char end = value . charAt ( i ) ; if ( end == '"' ) { int tail ; for ( tail = ++ i ; tail < len ; tail ++ ) { if ( value . charAt ( tail ) == end ) break ; } _readEncoding = Encoding . getMimeName ( value . substring ( i , tail ) ) ; return _readEncoding ; } int tail ; for ( tail = i ; tail < len ; tail ++ ) { if ( Character . isWhitespace ( value . charAt ( tail ) ) || value . charAt ( tail ) == ';' ) break ; } _readEncoding = Encoding . getMimeName ( value . substring ( i , tail ) ) ; return _readEncoding ; }
returns the character encoding of a post .
