.... Set up some character translations and predefined strings. \*(-- will
\fBASN1_STRING_print_ex() outputs str to out, the format is determined by the options flags. ASN1_STRING_print_ex_fp() is identical except it outputs to fp instead.
\fBASN1_STRING_print() prints str to out but using a different format to \fBASN1_STRING_print_ex(). It replaces unprintable characters (other than \s-1CR, LF\s0) with '.'.
\fBASN1_tag2str() returns a human-readable name of the specified \s-1ASN.1\s0 tag.
Although there are a large number of options frequently \s-1ASN1_STRFLGS_RFC2253\s0 is suitable, or on \s-1UTF8\s0 terminals \s-1ASN1_STRFLGS_RFC2253 &\s0 ~ASN1_STRFLGS_ESC_MSB.
The complete set of supported options for flags is listed below.
Various characters can be escaped. If \s-1ASN1_STRFLGS_ESC_2253\s0 is set the characters determined by \s-1RFC2253\s0 are escaped. If \s-1ASN1_STRFLGS_ESC_CTRL\s0 is set control characters are escaped. If \s-1ASN1_STRFLGS_ESC_MSB\s0 is set characters with the \s-1MSB\s0 set are escaped: this option should not be used if the terminal correctly interprets \s-1UTF8\s0 sequences.
Escaping takes several forms.
If the character being escaped is a 16 bit character then the form \*(L"\eUXXXX\*(R" is used using exactly four characters for the hex representation. If it is 32 bits then \*(L"\eWXXXXXXXX\*(R" is used using eight characters of its hex representation. These forms will only be used if \s-1UTF8\s0 conversion is not set (see below).
Printable characters are normally escaped using the backslash '\e' character. If \fB\s-1ASN1_STRFLGS_ESC_QUOTE\s0 is set then the whole string is instead surrounded by double quote characters: this is arguably more readable than the backslash notation. Other characters use the \*(L"\eXX\*(R" using exactly two characters of the hex representation.
If \s-1ASN1_STRFLGS_UTF8_CONVERT\s0 is set then characters are converted to \s-1UTF8\s0 format first. If the terminal supports the display of \s-1UTF8\s0 sequences then this option will correctly display multi byte characters.
If \s-1ASN1_STRFLGS_IGNORE_TYPE\s0 is set then the string type is not interpreted at all: everything is assumed to be one byte per character. This is primarily for debugging purposes and can result in confusing output in multi character strings.
If \s-1ASN1_STRFLGS_SHOW_TYPE\s0 is set then the string type itself is printed out before its value (for example \*(L"\s-1BMPSTRING\*(R"\s0), this actually uses ASN1_tag2str().
The content of a string instead of being interpreted can be \*(L"dumped\*(R": this just outputs the value of the string using the form #XXXX using hex format for each octet.
If \s-1ASN1_STRFLGS_DUMP_ALL\s0 is set then any type is dumped.
Normally non character string types (such as \s-1OCTET STRING\s0) are assumed to be one byte per character, if \s-1ASN1_STRFLGS_DUMP_UNKNOWN\s0 is set then they will be dumped instead.
When a type is dumped normally just the content octets are printed, if \fB\s-1ASN1_STRFLGS_DUMP_DER\s0 is set then the complete encoding is dumped instead (including tag and length octets).
\fB\s-1ASN1_STRFLGS_RFC2253\s0 includes all the flags required by \s-1RFC2253.\s0 It is equivalent to: \s-1ASN1_STRFLGS_ESC_2253\s0 | \s-1ASN1_STRFLGS_ESC_CTRL\s0 | \s-1ASN1_STRFLGS_ESC_MSB\s0 | \s-1ASN1_STRFLGS_UTF8_CONVERT\s0 | \s-1ASN1_STRFLGS_DUMP_UNKNOWN ASN1_STRFLGS_DUMP_DER\s0
\fBASN1_STRING_print() returns 1 on success or 0 on error.
\fBASN1_tag2str() returns a human-readable name of the specified \s-1ASN.1\s0 tag.
Licensed under the OpenSSL license (the \*(L"License\*(R"). You may not use this file except in compliance with the License. You can obtain a copy in the file \s-1LICENSE\s0 in the source distribution or at <https://www.openssl.org/source/license.html>.