@@ -1825,6 +1825,7 @@ && isEnabled(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT)) {
1825
1825
* fit in the output buffer regardless of UTF-8 expansion.
1826
1826
*/
1827
1827
private final int _shortUTF8Encode (char [] str , int i , int end )
1828
+ throws IOException
1828
1829
{
1829
1830
// First: let's see if it's all ASCII: that's rather fast
1830
1831
int ptr = _outputTail ;
@@ -1847,6 +1848,7 @@ private final int _shortUTF8Encode(char[] str, int i, int end)
1847
1848
* characters.
1848
1849
*/
1849
1850
private final int _shortUTF8Encode2 (char [] str , int i , int end , int outputPtr )
1851
+ throws IOException
1850
1852
{
1851
1853
final byte [] outBuf = _outputBuffer ;
1852
1854
while (i < end ) {
@@ -1892,6 +1894,7 @@ private final int _shortUTF8Encode2(char[] str, int i, int end, int outputPtr)
1892
1894
}
1893
1895
1894
1896
private final int _shortUTF8Encode (String str , int i , int end )
1897
+ throws IOException
1895
1898
{
1896
1899
// First: let's see if it's all ASCII: that's rather fast
1897
1900
int ptr = _outputTail ;
@@ -1909,6 +1912,7 @@ private final int _shortUTF8Encode(String str, int i, int end)
1909
1912
}
1910
1913
1911
1914
private final int _shortUTF8Encode2 (String str , int i , int end , int outputPtr )
1915
+ throws IOException
1912
1916
{
1913
1917
final byte [] outBuf = _outputBuffer ;
1914
1918
while (i < end ) {
@@ -2094,28 +2098,33 @@ private void _mediumUTF8Encode(String str, int inputPtr, int inputEnd) throws IO
2094
2098
/**
2095
2099
* Method called to calculate UTF codepoint, from a surrogate pair.
2096
2100
*/
2097
- private int _convertSurrogate (int firstPart , int secondPart )
2101
+ private int _convertSurrogate (int firstPart , int secondPart ) throws IOException
2098
2102
{
2099
2103
// Ok, then, is the second part valid?
2100
2104
if (secondPart < SURR2_FIRST || secondPart > SURR2_LAST ) {
2101
- throw new IllegalArgumentException ("Broken surrogate pair: first char 0x" +Integer .toHexString (firstPart )+", second 0x" +Integer .toHexString (secondPart )+"; illegal combination" );
2105
+ String msg = String .format ("Broken surrogate pair: first char 0x%04X, second 0x%04X; illegal combination" ,
2106
+ firstPart , secondPart );
2107
+ _reportError (msg );
2102
2108
}
2103
2109
return 0x10000 + ((firstPart - SURR1_FIRST ) << 10 ) + (secondPart - SURR2_FIRST );
2104
2110
}
2105
2111
2106
- private void _throwIllegalSurrogate (int code )
2112
+ private void _throwIllegalSurrogate (int code ) throws IOException
2107
2113
{
2108
2114
if (code > 0x10FFFF ) { // over max?
2109
- throw new IllegalArgumentException ("Illegal character point (0x" +Integer .toHexString (code )+") to output; max is 0x10FFFF as per RFC 4627" );
2115
+ _reportError (String .format (
2116
+ "Illegal character point (0x%X) to output; max is 0x10FFFF as per RFC 4627" , code ));
2110
2117
}
2111
2118
if (code >= SURR1_FIRST ) {
2112
2119
if (code <= SURR1_LAST ) { // Unmatched first part (closing without second part?)
2113
- throw new IllegalArgumentException ("Unmatched first part of surrogate pair (0x" +Integer .toHexString (code )+")" );
2120
+ _reportError (String .format (
2121
+ "Unmatched first part of surrogate pair (0x%04X)" , code ));
2114
2122
}
2115
- throw new IllegalArgumentException ("Unmatched second part of surrogate pair (0x" +Integer .toHexString (code )+")" );
2123
+ _reportError (String .format (
2124
+ "Unmatched second part of surrogate pair (0x%04X)" , code ));
2116
2125
}
2117
2126
// should we ever get this?
2118
- throw new IllegalArgumentException ( "Illegal character point (0x" + Integer . toHexString ( code )+ ") to output" );
2127
+ _reportError ( String . format ( "Illegal character point (0x%X) to output" , code ) );
2119
2128
}
2120
2129
2121
2130
/*
0 commit comments