Fix writeString not fully respecting charset

The string would be cut short for charsets
with characters more than 1 byte.
This commit is contained in:
P0nk
2023-03-02 18:11:41 +01:00
parent ab25f698da
commit 10945927c1

View File

@@ -71,8 +71,9 @@ public class ByteBufOutPacket implements OutPacket {
@Override
public void writeString(String value) {
writeShort((short) value.length());
writeBytes(value.getBytes(CharsetConstants.CHARSET));
byte[] bytes = value.getBytes(CharsetConstants.CHARSET);
writeShort(bytes.length);
writeBytes(bytes);
}
@Override