public static void prepareUnicode(final StringBuilder buffer,final ByteSequence sequence,final boolean trim,final boolean foldCase){
  Reject.ifNull(buffer,sequence);
  final int length=sequence.length();
  for (int i=0; i < length; i++) {
    final byte b=sequence.byteAt(i);
    if ((b & 0x7F) != b) {
      MappingTable.map(buffer,sequence.subSequence(i,length),trim,foldCase);
      String normalizedForm=Normalizer.normalize(buffer,Form.NFKD);
      buffer.setLength(0);
      buffer.append(normalizedForm);
      break;
    }
switch (b) {
case ' ':
      if (canMapToSpace(buffer,trim)) {
        buffer.append(' ');
      }
    break;
default :
  if (b >= '\u0009' && b < '\u000E') {
    if (canMapToSpace(buffer,trim)) {
      buffer.append(SPACE_CHAR);
    }
  }
 else   if ((b >= '\u0000' && b <= '\u0008') || (b >= '\u000E' && b <= '\u001F') || b == '\u007F') {
    break;
  }
 else   if (foldCase && b >= 'A' && b <= 'Z') {
    buffer.append((char)(b + 32));
  }
 else {
    buffer.append((char)b);
  }
break;
}
}
if (trim) {
for (int i=buffer.length() - 1; i > 0; i--) {
if (buffer.charAt(i) == SPACE_CHAR) {
buffer.delete(i,i + 1);
}
 else {
break;
}
}
}
}

public static void prepareUnicode ( final StringBuilder buffer , final ByteSequence sequence , final boolean trim , final boolean foldCase ) { Reject . ifNull ( buffer , sequence ) ; final int length = sequence . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { final byte b = sequence . byteAt ( i ) ; if ( ( b & 0x7F ) != b ) { MappingTable . map ( buffer , sequence . subSequence ( i , length ) , trim , foldCase ) ; String normalizedForm = Normalizer . normalize ( buffer , Form . NFKD ) ; buffer . setLength ( 0 ) ; buffer . append ( normalizedForm ) ; break ; } switch ( b ) { case ' ' : if ( canMapToSpace ( buffer , trim ) ) { buffer . append ( ' ' ) ; } break ; default : if ( b >= '	' && b < '' ) { if ( canMapToSpace ( buffer , trim ) ) { buffer . append ( SPACE_CHAR ) ; } } else if ( ( b >= '' && b <= '' ) || ( b >= '' && b <= '' ) || b == '' ) { break ; } else if ( foldCase && b >= 'A' && b <= 'Z' ) { buffer . append ( ( char ) ( b + 32 ) ) ; } else { buffer . append ( ( char ) b ) ; } break ; } } if ( trim ) { for ( int i = buffer . length ( ) - 1 ; i > 0 ; i -- ) { if ( buffer . charAt ( i ) == SPACE_CHAR ) { buffer . delete ( i , i + 1 ) ; } else { break ; } } } }
prepares an attribute or assertion value as per stringprep algorithm defined in rfc 4518 .
