private static String mungeCharName(String source){
  StringBuffer buf=new StringBuffer();
  for (int i=0; i < source.length(); ) {
    int ch=UTF16.charAt(source,i);
    i+=UTF16.getCharCount(ch);
    if (UCharacterProperty.isRuleWhiteSpace(ch)) {
      if (buf.length() == 0 || buf.charAt(buf.length() - 1) == ' ') {
        continue;
      }
      ch=' ';
    }
    UTF16.append(buf,ch);
  }
  if (buf.length() != 0 && buf.charAt(buf.length() - 1) == ' ') {
    buf.setLength(buf.length() - 1);
  }
  return buf.toString();
}

private static String mungeCharName ( String source ) { StringBuffer buf = new StringBuffer ( ) ; for ( int i = 0 ; i < source . length ( ) ; ) { int ch = UTF16 . charAt ( source , i ) ; i += UTF16 . getCharCount ( ch ) ; if ( UCharacterProperty . isRuleWhiteSpace ( ch ) ) { if ( buf . length ( ) == 0 || buf . charAt ( buf . length ( ) - 1 ) == ' ' ) { continue ; } ch = ' ' ; } UTF16 . append ( buf , ch ) ; } if ( buf . length ( ) != 0 && buf . charAt ( buf . length ( ) - 1 ) == ' ' ) { buf . setLength ( buf . length ( ) - 1 ) ; } return buf . toString ( ) ; }
remove leading and trailing rule white space and compress internal rule white space to a single space character .
