default:
{
if ( !XMLChar.isValid(ch)) {
if (XMLChar.isHighSurrogate(ch)) {
char high = ch;
if (inputLength-- > 0) {
ch = input.charAt(inputPos++);
if (XMLChar.isLowSurrogate(ch)) {
if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT) {
// Every codepoint is supported!
value[outputPos++ ] = high;
value[outputPos++ ] = ch;
}
else {
// Produce the supplemental character as an entity
outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);
changed = true;
}
break;
}
throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
}
else {
throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
}
}
else {
throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);
}
}
else {
// Normal (BMP) unicode code point. See if we know for a fact that the encoding supports it:
if (ch <= mappableLimit) {
value[outputPos++ ] = ch;
}
else {
// We not sure the encoding supports this code point, so we write it as a character entity reference.
outputPos = replaceChars(outputPos, ("&#x" + Integer.toHexString(ch) + ";").toCharArray(), inputLength);
changed = true;
}
}
break;
}
|