Skip to content

Commit a69782e

Browse files
author
Mark
committed
fixed VelocyPack bug with non-ASCII characters
1 parent a4c6ab1 commit a69782e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/java/com/arangodb/velocypack/VPackBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ private void appendSQLTimestamp(final Timestamp value) {
611611
}
612612

613613
private void appendString(final String value) throws VPackBuilderException {
614-
final int length = value.length();
614+
final int length = value.getBytes().length;
615615
if (length <= 126) {
616616
// short string
617617
add((byte) (0x40 + length));

src/test/java/com/arangodb/velocypack/VPackBuilderTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,4 +887,12 @@ public void addVPackObjectInArray() throws VPackException {
887887
}
888888
}
889889

890+
@Test
891+
public void nonASCII() {
892+
final String s = "·ÃÂ";
893+
final VPackSlice vpack = new VPackBuilder().add(s).slice();
894+
assertThat(vpack.isString(), is(true));
895+
assertThat(vpack.getAsString(), is(s));
896+
}
897+
890898
}

0 commit comments

Comments
 (0)