File tree 4 files changed +15
-4
lines changed
main/java/com/fasterxml/jackson/core/io
test/java/com/fasterxml/jackson/core/io
4 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -432,3 +432,5 @@ Antonin Janec (@xtonic)
432
432
(2.17.0 )
433
433
* Contributed #1217 : Optimize char comparison using bitwise OR
434
434
(2.17.0 )
435
+ * Contributed #1218 : Simplify Unicode surrogate pair conversion for generation
436
+ (2.17.0 )
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ a pure JSON library.
45
45
(reported by @denizk )
46
46
#1217 : Optimize char comparison using bitwise OR
47
47
(contributed by @xtonik )
48
+ #1218 : Simplify Unicode surrogate pair conversion for generation
49
+ (contributed by @xtonik )
48
50
49
51
2.16 .2 (not yet released )
50
52
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ public final class UTF8Writer extends Writer
9
9
final static int SURR2_FIRST = 0xDC00 ;
10
10
final static int SURR2_LAST = 0xDFFF ;
11
11
12
+ /**
13
+ * @since 2.17
14
+ */
12
15
public static final int SURROGATE_BASE = 0x10000 - UTF8Writer .SURR2_FIRST - (UTF8Writer .SURR1_FIRST << 10 );
13
16
14
17
final private IOContext _context ;
Original file line number Diff line number Diff line change 3
3
import java .io .*;
4
4
5
5
import org .junit .Assert ;
6
- import org .junit .Ignore ;
7
6
8
7
public class UTF8WriterTest
9
8
extends com .fasterxml .jackson .core .BaseTest
@@ -137,13 +136,18 @@ public void testSurrogatesFail() throws Exception
137
136
}
138
137
}
139
138
140
- @ Ignore
141
- public void testSurrogateConversion () {
139
+ // For [core#1218]
140
+ // @since 2.17
141
+ public void testSurrogateConversion ()
142
+ {
142
143
for (int first = UTF8Writer .SURR1_FIRST ; first <= UTF8Writer .SURR1_LAST ; first ++) {
143
144
for (int second = UTF8Writer .SURR2_FIRST ; second <= UTF8Writer .SURR2_LAST ; second ++) {
144
145
int expected = 0x10000 + ((first - UTF8Writer .SURR1_FIRST ) << 10 ) + (second - UTF8Writer .SURR2_FIRST );
145
146
int actual = (first << 10 ) + second + UTF8Writer .SURROGATE_BASE ;
146
- assertEquals (Integer .toHexString (first ) + " " + Integer .toHexString (second ), expected , actual );
147
+ if (expected != actual ) {
148
+ fail ("Mismatch on: " +Integer .toHexString (first ) + " " + Integer .toHexString (second )
149
+ +"; expected: " +expected +", actual: " +actual );
150
+ }
147
151
}
148
152
}
149
153
}
You can’t perform that action at this time.
0 commit comments