public static String HTMLEntityEncode ( String input ) { String next = scriptPattern . matcher ( input ) . replaceAll ( "&#x73;cript" ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < next . length ( ) ; ++ i ) { char ch = next . charAt ( i ) ; if ( ch == ' ' ) { sb . append ( "&lt;" ) ; } else if ( ch == ' ' ) { sb . append ( "&gt;" ) ; } else { sb . append ( ch ) ; } } return sb . toString ( ) ; }
Encode HTML entities .