code: public static int computeStringSizeNoTag(final String value) {
      try {
        final byte[] bytes = value.getBytes("UTF-8");
        return computeRawVarint32Size(bytes.length) +
               bytes.length;
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("UTF-8 not supported.", e);
      }
    }
docs: Compute the number of bytes that would be needed to encode a
  {@code string} field.