Improved test, fixed bug

This commit is contained in:
2017-01-23 22:33:39 +01:00
parent def99f7a7c
commit 7a84d1e220
2 changed files with 4 additions and 3 deletions

View File

@ -66,7 +66,8 @@ public class MPString implements MPType<String>, CharSequence {
}
public void pack(OutputStream out) throws IOException {
int size = value.length();
byte[] bytes = value.getBytes(encoding);
int size = bytes.length;
if (size < 32) {
out.write(FIXSTR_PREFIX + size);
} else if (size < STR8_LIMIT) {
@ -79,7 +80,7 @@ public class MPString implements MPType<String>, CharSequence {
out.write(STR32_PREFIX);
out.write(ByteBuffer.allocate(4).putInt(size).array());
}
out.write(value.getBytes(encoding));
out.write(bytes);
}
@Override