protected byte[] stringToByte_8859_1(String str) throws SaslException {
  char[] buffer=str.toCharArray();
  try {
    if (useUTF8) {
      for (int i=0; i < buffer.length; i++) {
        if (buffer[i] > '\u00FF') {
          return str.getBytes("UTF8");
        }
      }
    }
    return str.getBytes("8859_1");
  }
 catch (  UnsupportedEncodingException e) {
    throw new SaslException("cannot encode string in UTF8 or 8859-1 (Latin-1)",e);
  }
}

protected byte [ ] stringToByte_8859_1 ( String str ) throws SaslException { char [ ] buffer = str . toCharArray ( ) ; try { if ( useUTF8 ) { for ( int i = 0 ; i < buffer . length ; i ++ ) { if ( buffer [ i ] > 'ÿ' ) { return str . getBytes ( "UTF8" ) ; } } } return str . getBytes ( "8859_1" ) ; } catch ( UnsupportedEncodingException e ) { throw new SaslException ( "cannot encode string in UTF8 or 8859-1 (Latin-1)" , e ) ; } }
used to convert username - value , passwd or realm to 8859_1 encoding if all chars in string are within the 8859_1 ( latin 1 ) encoding range .
