public static boolean isValidXMLCharacter ( int codepoint ) { // Most of the time the character will be valid. Order the tests such // that most valid characters will be found in the minimum number of // tests. if ( codepoint >= 0x20 && codepoint <= 0xD7FF ) { return true ; } else if ( codepoint == 0x9 || codepoint == 0xA || codepoint == 0xD ) { return true ; } else if ( codepoint >= 0xE000 && codepoint <= 0xFFFD ) { return true ; } else if ( codepoint >= 0x10000 && codepoint <= 0x10FFFF ) { return true ; } else { return false ; } }
Determine if a given UNICODE character can appear in a valid XML file . The allowed characters are 0x9 0xA 0xD 0x20 - 0xD7FF 0xE000 - 0xFFFD and 0x100000 - 0x10FFFF ; all other characters may not appear in an XML file .