Skip to content

Commit bbf249b

Browse files
committed
Update release notes wrt #1218
1 parent 11280d4 commit bbf249b

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

release-notes/CREDITS-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,5 @@ Antonin Janec (@xtonic)
432432
(2.17.0)
433433
* Contributed #1217: Optimize char comparison using bitwise OR
434434
(2.17.0)
435+
* Contributed #1218: Simplify Unicode surrogate pair conversion for generation
436+
(2.17.0)

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ a pure JSON library.
4545
(reported by @denizk)
4646
#1217: Optimize char comparison using bitwise OR
4747
(contributed by @xtonik)
48+
#1218: Simplify Unicode surrogate pair conversion for generation
49+
(contributed by @xtonik)
4850

4951
2.16.2 (not yet released)
5052

src/main/java/com/fasterxml/jackson/core/io/UTF8Writer.java

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ public final class UTF8Writer extends Writer
99
final static int SURR2_FIRST = 0xDC00;
1010
final static int SURR2_LAST = 0xDFFF;
1111

12+
/**
13+
* @since 2.17
14+
*/
1215
public static final int SURROGATE_BASE = 0x10000 - UTF8Writer.SURR2_FIRST - (UTF8Writer.SURR1_FIRST << 10);
1316

1417
final private IOContext _context;

src/test/java/com/fasterxml/jackson/core/io/UTF8WriterTest.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.*;
44

55
import org.junit.Assert;
6-
import org.junit.Ignore;
76

87
public class UTF8WriterTest
98
extends com.fasterxml.jackson.core.BaseTest
@@ -137,13 +136,18 @@ public void testSurrogatesFail() throws Exception
137136
}
138137
}
139138

140-
@Ignore
141-
public void testSurrogateConversion() {
139+
// For [core#1218]
140+
// @since 2.17
141+
public void testSurrogateConversion()
142+
{
142143
for (int first = UTF8Writer.SURR1_FIRST; first <= UTF8Writer.SURR1_LAST; first++) {
143144
for (int second = UTF8Writer.SURR2_FIRST; second <= UTF8Writer.SURR2_LAST; second++) {
144145
int expected = 0x10000 + ((first - UTF8Writer.SURR1_FIRST) << 10) + (second - UTF8Writer.SURR2_FIRST);
145146
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+
}
147151
}
148152
}
149153
}

0 commit comments

Comments
 (0)