public static void xmlEscape ( StringBuilder sb , Reader r ) throws ParseException { try { int c ; StringBuilder esc = new StringBuilder ( ) ; for ( int cnt = 0 ; cnt < 9 /*max*/ ; ++ cnt ) { if ( ( c = r . read ( ) ) < 0 ) throw new ParseException ( "Invalid Data: Unfinished Escape Sequence" ) ; if ( c != ' ' ) { esc . append ( ( char ) c ) ; } else { // evaluate Integer i = charMap . get ( esc . toString ( ) ) ; if ( i == null ) { // leave in nasty XML format for now. sb . append ( ' ' ) ; sb . append ( esc ) ; sb . append ( ' ' ) ; } else { sb . append ( ( char ) i . intValue ( ) ) ; } break ; } } } catch ( IOException e ) { throw new ParseException ( e ) ; } }
see initialization at end