code: public static boolean containsIllegalXML(String str) {
          assert str != null;
          for (int index = 0; index < str.length(); index++) {
              char ch = str.charAt(index);
              if ((ch <= 0x08) ||
                  (ch >= 0x0B && ch <= 0x0C) ||
                  (ch >= 0x0E && ch <= 0x19) ||
                  (ch >= 0xD800 && ch <= 0xDFFF) ||
                  (ch >= 0xFFFE)) {
                  return true;
              }
          }
          return false;
      }
docs: Returns true if the given string contains any characters that are considered illegal
  in XML. See http://www.w3.org/TR/xml/#charsets. The legal XML characters XML are:
  <pre>
  #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
  </pre>
  Note that Java String chars can only be up to 0xFFFF
  
  @param   str Non-null string to be tested.
  @return      True if the string contains a character considered illegal in XML.