1 | if (!XMLChar.isValid(ch))↵ | | 1 | if (!XMLChar.isValid(ch))↵
|
2 | {↵ | | 2 | {↵
|
3 | if (XMLChar.isHighSurrogate(ch))↵ | | 3 | if (XMLChar.isHighSurrogate(ch))↵
|
4 | {↵ | | 4 | {↵
|
5 | char high = ch;↵ | | 5 | char high = ch;↵
|
6 | if (inputLength-- > 0)↵ | | 6 | if (inputLength-- > 0)↵
|
7 | {↵ | | 7 | {↵
|
8 | ch = input.charAt(inputPos++); ↵ | | 8 | ch = input.charAt(inputPos++); ↵
|
9 | if (XMLChar.isLowSurrogate(ch))↵ | | 9 | if (XMLChar.isLowSurrogate(ch))↵
|
10 | {↵ | | 10 | {↵
|
11 | if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)↵ | | 11 | if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)↵
|
12 | {↵ | | 12 | {↵
|
13 | // Every codepoint is supported! ↵ | | 13 | // Every codepoint is supported! ↵
|
14 | value[outputPos++] = high;↵ | | 14 | value[outputPos++] = high;↵
|
15 | value[outputPos++] = ch;↵ | | 15 | value[outputPos++] = ch;↵
|
16 | }↵ | | 16 | }↵
|
17 | else↵ | | 17 | else↵
|
18 | {↵ | | 18 | {↵
|
19 | // Produce the supplemental character as an entity↵ | | 19 | // Produce the supplemental character as an entity↵
|
20 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);↵ | | 20 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);↵
|
21 | changed = true;↵ | | 21 | changed = true;↵
|
22 | }↵ | | 22 | }↵
|
23 | break;↵ | | 23 | break;↵
|
24 | }↵ | | 24 | }↵
|
25 | throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | | 25 | throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵
|
26 | }↵ | | 26 | }↵
|
27 | else↵ | | 27 | else↵
|
28 | {↵ | | 28 | {↵
|
29 | throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | | 29 | throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵
|
30 | }↵ | | 30 | }↵
|
31 | }↵ | | 31 | }↵
|
32 | else↵ | | 32 | else↵
|
33 | {↵ | | 33 | {↵
|
34 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | | 34 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵
|
35 | }↵ | | 35 | }↵
|
36 | }↵ | | 36 | }↵
|
37 | else↵ | | 37 | else↵
|
38 | {↵ | | 38 | {↵
|
39 | // Normal (BMP) unicode code point. See if we know for a fact that the encoding supports it:↵ | | 39 | // Normal (BMP) unicode code point. See if we know for a fact that the encoding supports it:↵
|
40 | if (ch <= mappableLimit)↵ | | 40 | if (ch <= mappableLimit)↵
|
41 | {↵ | | 41 | {↵
|
42 | value[outputPos++] = ch;↵ | | 42 | value[outputPos++] = ch;↵
|
43 | }↵ | | 43 | }↵
|
44 | else↵ | | 44 | else↵
|
45 | {↵ | | 45 | {↵
|
46 | // We not sure the encoding supports this code point, so we write it as a character entity reference.↵ | | 46 | // We not sure the encoding supports this code point, so we write it as a character entity reference.↵
|
47 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(ch) + ";").toCharArray(), inputLength);↵ | | 47 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(ch) + ";").toCharArray(), inputLength);↵
|
48 | changed = true;↵ | | 48 | changed = true;↵
|
49 | }↵ | | 49 | }↵
|
50 | }↵ | | 50 | }↵
|
51 | break;↵ | | 51 | break;↵
|
52 | | | 52 |
|