Skip to content

Commit

Permalink
fix(sumo): send strings via traci correctly respecting characters usi…
Browse files Browse the repository at this point in the history
…ng more than 1 byte, e.g. 🚗 (#359)
  • Loading branch information
kschrab authored Oct 27, 2023
1 parent 1999ffd commit c2df711
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@ public StringTraciWriter(String fixedValue) {

@Override
public int getVariableLength(String argument) {
return getLength() + argument.length();
return getLength() + argument.getBytes(StandardCharsets.UTF_8).length;
}

@Override
public void write(DataOutputStream out) throws IOException {
out.writeInt(value.length());
out.write(value.getBytes(StandardCharsets.UTF_8));
byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
out.writeInt(bytes.length);
out.write(bytes);
}

@Override
public void writeVariableArgument(DataOutputStream out, String argument) throws IOException {
out.writeInt(argument.length());
out.write(argument.getBytes(StandardCharsets.UTF_8));
byte[] bytes = argument.getBytes(StandardCharsets.UTF_8);
out.writeInt(bytes.length);
out.write(bytes);
}
}

0 comments on commit c2df711

Please sign in to comment.