Skip to content

Commit

Permalink
fix merge problems
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 5, 2025
1 parent 579c394 commit d83012a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/tools/jackson/core/json/UTF8JsonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ private final void _writeCustomStringSegment2(final char[] cbuf, int offset, fin
} else {
// 3- or 4-byte character
if (_isStartOfSurrogatePair(ch)) {
final boolean combineSurrogates = Feature.COMBINE_UNICODE_SURROGATES_IN_UTF8.enabledIn(_features);
final boolean combineSurrogates = JsonWriteFeature.COMBINE_UNICODE_SURROGATES_IN_UTF8.enabledIn(_formatWriteFeatures);
if (combineSurrogates && offset < end) {
char highSurrogate = (char) ch;
char lowSurrogate = cbuf[offset++];
Expand Down Expand Up @@ -1839,7 +1839,7 @@ private final void _writeCustomStringSegment2(final String text, int offset, fin
} else {
// 3- or 4-byte character
if (_isStartOfSurrogatePair(ch)) {
final boolean combineSurrogates = Feature.COMBINE_UNICODE_SURROGATES_IN_UTF8.enabledIn(_features);
final boolean combineSurrogates = JsonWriteFeature.COMBINE_UNICODE_SURROGATES_IN_UTF8.enabledIn(_formatWriteFeatures);
if (combineSurrogates && offset < end) {
char highSurrogate = (char) ch;
char lowSurrogate = text.charAt(offset++);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import tools.jackson.core.json.JsonFactory;
import tools.jackson.core.json.JsonWriteFeature;
import tools.jackson.core.unittest.*;
import tools.jackson.core.util.JsonpCharacterEscapes;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -131,13 +132,13 @@ void checkNonSurrogates() throws Exception {
void checkSurrogateWithCharacterEscapes() throws Exception {
JsonFactory f = JsonFactory.builder()
.enable(JsonWriteFeature.COMBINE_UNICODE_SURROGATES_IN_UTF8)
.characterEscapes(JsonpCharacterEscapes.instance())
.build();
f.setCharacterEscapes(JsonpCharacterEscapes.instance());
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (JsonGenerator gen = f.createGenerator(out)) {
try (JsonGenerator gen = f.createGenerator(ObjectWriteContext.empty(), out)) {
gen.writeStartObject();
// Outside the BMP; 0x1F60A - emoji
gen.writeStringField("test_emoji", new String(Character.toChars(0x1F60A)));
gen.writeStringProperty("test_emoji", new String(Character.toChars(0x1F60A)));
gen.writeEndObject();
}
String json = out.toString("UTF-8");
Expand Down

0 comments on commit d83012a

Please sign in to comment.