Here you can find the source of substituteSelectedCharacters(String text, boolean skip)
public static String substituteSelectedCharacters(String text, boolean skip)
//package com.java2s; /*//from w ww .j ava2 s.c o m * Id: * * Copyright (C) 2004, Cladonia Ltd. All rights reserved. * * This software is the proprietary information of Cladonia Ltd. * Use is subject to license terms. */ public class Main { /** * Substitutes the selected characters with entities. */ public static String substituteSelectedCharacters(String text, boolean skip) { if (text != null) { StringBuffer newText = new StringBuffer(); for (int i = 0; i < text.length(); i++) { char character = text.charAt(i); if (character == '<') { if (skip) newText.append("<"); else newText.append((char) character); } else if (character == '>') { if (skip) newText.append(">"); else newText.append((char) character); } else if (character == '&') { if (skip) { newText.append("&"); } else { newText.append((char) character); } } else if (character == '\'') { if (skip) newText.append("'"); else newText.append((char) character); } else if (character == '\"') { if (skip) newText.append("""); else newText.append((char) character); /*} else if ( character > 127) { if(!skip) { String name = CommonEntities.getEntityName( character); try { if ( !name.equals( "lt") && !name.equals( "gt") && !name.equals( "amp") && !name.equals( "apos") && !name.equals( "quot")) { newText.append( "&"); newText.append( name); newText.append( ";"); } } catch (NullPointerException e) { //problem with converting char to entity //just use that char newText.append((char)character); } } else { newText.append( (char)character); }*/ } else { newText.append((char) character); } } return (newText.toString()); } else { return (text); } } }