question: public static String escapeHTML ( String str , short version ) { String [ ] [ ] data ; int [ ] offset ; StringBuilder rtn = new StringBuilder ( str . length ( ) ) ; char [ ] chars = str . toCharArray ( ) ; if ( version == HTMLV20 ) { data = HTML20_DATA ; offset = HTML20_OFFSET ; } else if ( version == HTMLV32 ) { data = HTML32_DATA ; offset = HTML32_OFFSET ; } else { data = HTML40_DATA ; offset = HTML40_OFFSET ; } outer : for ( int i = 0 ; i < chars . length ; i ++ ) { char c = chars [ i ] ; if ( c == CR ) continue ; for ( int y = 0 ; y < offset . length ; y ++ ) { if ( c >= offset [ y ] && c < data [ y ] . length + offset [ y ] ) { String replacement = data [ y ] [ c - offset [ y ] ] ; if ( replacement != null ) { rtn . append ( '&' ) ; rtn . append ( replacement ) ; rtn . append ( ';' ) ; continue outer ; } } } rtn . append ( c ) ; } return rtn . toString ( ) ; }
target:  escapes html character inside a string