fix: unicode in chat
This commit is contained in:
@@ -32,7 +32,7 @@ public abstract class NetOutputStream_p340 extends NetOutputStream {
|
|||||||
writeBytes(buf);
|
writeBytes(buf);
|
||||||
} else {
|
} else {
|
||||||
byte[] buf = value.getBytes(StandardCharsets.UTF_8);
|
byte[] buf = value.getBytes(StandardCharsets.UTF_8);
|
||||||
writeVarInt(value.length());
|
writeVarInt(buf.length);
|
||||||
writeBytes(buf);
|
writeBytes(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ class ByteArrayOutputNetStreamTest {
|
|||||||
|
|
||||||
final byte[] strBytes = string.getBytes(StandardCharsets.UTF_8);
|
final byte[] strBytes = string.getBytes(StandardCharsets.UTF_8);
|
||||||
final byte[] bytes = new byte[strBytes.length + 1];
|
final byte[] bytes = new byte[strBytes.length + 1];
|
||||||
bytes[0] = (byte) string.length(); // здесь считается, что размер поместится в один байт
|
bytes[0] = (byte) strBytes.length; // здесь считается, что размер поместится в один байт
|
||||||
System.arraycopy(strBytes, 0, bytes, 1, strBytes.length);
|
System.arraycopy(strBytes, 0, bytes, 1, strBytes.length);
|
||||||
|
|
||||||
assertArrayEquals(bytes, byteArrayOutputNetStream.toByteArray());
|
assertArrayEquals(bytes, byteArrayOutputNetStream.toByteArray());
|
||||||
|
|||||||
Reference in New Issue
Block a user