Here you can find the source of sanitizeString(String input)
public static String sanitizeString(String input)
//package com.java2s; //License from project: Apache License public class Main { public static String sanitizeString(String input) { // sanitize the content // get document text if (input != null) { char[] docCharArray = input.toCharArray(); replaceInvalidXmlChars(docCharArray); return String.valueOf(docCharArray); }/* w w w . j a va2 s . co m*/ return input; } private static void replaceInvalidXmlChars(char[] aChars) { for (int i = 0; i < aChars.length; i++) { if ((aChars[i] < 0x20 && aChars[i] != 0x09 && aChars[i] != 0x0A && aChars[i] != 0x0D) || (aChars[i] > 0xD7FF && aChars[i] < 0xE000) || aChars[i] == 0xFFFE || aChars[i] == 0xFFFF) { // System.out.println("Found invalid XML character: " + (int)aChars[i] + " at position " + // i); //temp aChars[i] = ' '; } } } }