Skip to content

Commit

Permalink
Merge pull request #231 from itchyny/fix-explode-utf8-codepoint
Browse files Browse the repository at this point in the history
Fix explode/0 against Unicode surrogate code points
  • Loading branch information
eiiches authored Nov 20, 2022
2 parents f9ca0e5 + f7b0b0b commit 55f57df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public void apply(final Scope scope, final List<Expression> args, final JsonNode
Preconditions.checkInputType("explode", in, JsonNodeType.STRING);

final ArrayNode result = scope.getObjectMapper().createArrayNode();
for (final char ch : in.asText().toCharArray())
result.add((int) ch);
for (final int ch : in.asText().codePoints().toArray())
result.add(ch);
output.emit(result, null);
}
}
4 changes: 4 additions & 0 deletions jackson-jq/src/test/resources/tests/functions/explode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- q: 'explode'
in: "\\ud83d\\ude04"
out:
- 128516

0 comments on commit 55f57df

Please sign in to comment.