Skip to content

Commit

Permalink
Fix bug calculating buffer size with non-ascii chars
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmudd committed Dec 13, 2024
1 parent 3c6ca36 commit 30b964d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jhdf/src/main/java/io/jhdf/object/datatype/StringData.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void setBufferLimit(ByteBuffer byteBuffer) {
public static StringData create(Object data) {
int maxLength = Arrays.stream(Utils.flatten(data))
.map(String.class::cast)
.mapToInt(String::length)
.mapToInt(s -> StandardCharsets.UTF_8.encode(s).limit())
.max().getAsInt();

return new StringData(PaddingType.NULL_TERMINATED, StandardCharsets.UTF_8, maxLength);
Expand Down

0 comments on commit 30b964d

Please sign in to comment.