code: public static int encodeIA5String(String value, ByteBuffer buf) {
          int pos = buf.position();
          byte[] data = (value == null) ? new byte[0] : value.getBytes();
          for (int i = data.length - 1; i >= 0; i--) {
              pos--;
              buf.put(pos, data[i]);
          }
          buf.position(buf.position() - data.length);
          int headerLength = DerUtils.encodeIdAndLength(DerId.TagClass.UNIVERSAL, DerId.EncodingType.PRIMITIVE,
                  ASN1_IA5STRING_TAG_NUM, data.length, buf);
          return headerLength + data.length;
      }
docs: Encode an ASN.1 IA5String.
  
  @param value
  the value to be encoded
  @param buf
  the buffer with space to the left of current position where the value will be encoded
  @return the length of the encoded data