docs: @Override
    public ByteBuffer serialize(String object) {
      int length = object.length();
  
      try(ByteArrayOutputStream bout = new ByteArrayOutputStream(length)) {
        int i = 0;
  
        for (; i < length; i++) {
          char c = object.charAt(i);
          if (c == 0x0000 || c > 0x007f) {
            break;
          }
          bout.write(c);
        }
  
        for (; i < length; i++) {
          char c = object.charAt(i);
          if (c == 0x0000) {
            bout.write(0xc0);
            bout.write(0x80);
          } else if (c < 0x0080) {
            bout.write(c);
          } else if (c < 0x800) {
            bout.write(0xc0 | ((c >>> 6) & 0x1f));
            bout.write(0x80 | (c & 0x3f));
          } else {
            bout.write(0xe0 | ((c >>> 12) & 0x1f));
            bout.write(0x80 | ((c >>> 6) & 0x3f));
            bout.write(0x80 | (c & 0x3f));
          }
        }
  
        return ByteBuffer.wrap(bout.toByteArray());
  
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }