private boolean isInvalid(String value) {
        char[] ch = value.toCharArray();

        int i = 0;
        while (i < ch.length) {
            int c = Character.codePointAt(ch, i);
            if (isInvalid(c)) {
                return true;
            }
            i = i + Character.charCount(c);
        }

        return false;
    }
Checks if the given string contains any invalid XML characters.

@param value string to be checked
@return <code>true</code> if the string contains invalid XML characters,
<code>false</code> otherwise
tika-core/src/main/java/org/apache/tika/sax/SafeContentHandler.java