public static String unescapeSpaces ( String in ) { char [ ] chars = in . toCharArray ( ) ; int end = chars . length ; StringBuffer out = new StringBuffer ( in . length ( ) ) ; for ( int i = 0 ; i < end ; i ++ ) { /* * Remove any backslashes that precede spaces. */ boolean isSlashSpace = ( chars [ i ] == ' ' ) && ( i + 1 < end ) && ( chars [ i + 1 ] == ' ' ) ; if ( isSlashSpace ) { boolean isStart = ( i > 0 ) && ( chars [ i - 1 ] == ' ' ) ; boolean isEnd = ( i + 2 >= end ) || ( ( i + 2 < end ) && ( chars [ i + 2 ] == ' ' ) ) ; if ( ! isStart && ! isEnd ) { ++ i ; } } out . append ( chars [ i ] ) ; } return new String ( out ) ; }
Replace any unnecessary escaped spaces from the input DN .