private String forceAscii(StringBuilder source) {
		int length = source.length();
		StringBuilder res = new StringBuilder(length);
		for (int i = 0; i < length; i++) {
			char c = source.charAt(i);
			if ((c >= SAFE_ASCII_LOWER && c <= SAFE_ASCII_UPPER) || Character.isSpaceChar(c)) {
				res.append(c);
			} else {
				res.append("\\u");
				String scode = Integer.toHexString(i);
				while (scode.length() < 4) {
					scode = "0" + scode;
				}
				res.append(scode);
			}
		}
		return res.toString();
	}
private String forceAscii ( StringBuilder source ) { int length = source . length ( ) ; StringBuilder res = new StringBuilder ( length ) ; for ( int i = 0 ; i < length ; i ++ ) { char c = source . charAt ( i ) ; if ( ( c >= SAFE_ASCII_LOWER && c <= SAFE_ASCII_UPPER ) || Character . isSpaceChar ( c ) ) { res . append ( c ) ; } else { res . append ( "\\u" ) ; String scode = Integer . toHexString ( i ) ; while ( scode . length ( ) < 4 ) { scode = "0" + scode ; } res . append ( scode ) ; } } return res . toString ( ) ; }
Convert StringBuilder output to a string while escaping characters. This prevents outputting control characters
and unreadable characters. It seems both cause problems for certain editors.
<p/>
The ASCII characters (excluding controls characters) are copied to the result as is, other characters are
escaped using \\uxxxx notation. Note that string comparisons on this result may be inaccurate as both (Java
strings) "\\u1234" and "\u1234" will produce the same converted string!

@param source StringBuilder to convert
@return String representation using only ASCI characters