
#use wml::openssl-macros area=docs page=ASN1_STRING_print_ex

<title>Documents, ASN1_STRING_print_ex(3)</title>

<h1>ASN1_STRING_print_ex(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
	<LI><A HREF="#HISTORY">HISTORY</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
ASN1_STRING_print_ex, ASN1_STRING_print_ex_fp - ASN1_STRING output
routines.

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/asn1.h&gt;
</PRE>
<PRE> int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
 int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
 int ASN1_STRING_print(BIO *out, ASN1_STRING *str);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
These functions output an <STRONG>ASN1_STRING</STRONG> structure. <STRONG>ASN1_STRING</STRONG> is used to represent all the ASN1 string types.

</P>
<P>
<CODE>ASN1_STRING_print_ex()</CODE> outputs <STRONG>str</STRONG> to <STRONG>out</STRONG>, the format is determined by the options <STRONG>flags</STRONG>. <CODE>ASN1_STRING_print_ex_fp()</CODE> is identical except it outputs to <STRONG>fp</STRONG> instead.

</P>
<P>
<CODE>ASN1_STRING_print()</CODE> prints <STRONG>str</STRONG> to <STRONG>out</STRONG> but using a different format to <CODE>ASN1_STRING_print_ex().</CODE> It
replaces unprintable characters (other than CR, LF) with '.'.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
<CODE>ASN1_STRING_print()</CODE> is a legacy function which should be
avoided in new applications.

</P>
<P>
Although there are a large number of options frequently <STRONG>ASN1_STRFLGS_RFC2253</STRONG> is suitable, or on UTF8 terminals <STRONG>ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB</STRONG>.

</P>
<P>
The complete set of supported options for <STRONG>flags</STRONG> is listed below.

</P>
<P>
Various characters can be escaped. If <STRONG>ASN1_STRFLGS_ESC_2253</STRONG> is set the characters determined by RFC2253 are escaped. If <STRONG>ASN1_STRFLGS_ESC_CTRL</STRONG> is set control characters are escaped. If <STRONG>ASN1_STRFLGS_ESC_MSB</STRONG> is set characters with the MSB set are escaped: this option should <STRONG>not</STRONG> be used if the terminal correctly interprets UTF8 sequences.

</P>
<P>
Escaping takes several forms.

</P>
<P>
If the character being escaped is a 16 bit character then the form
``\UXXXX'' is used using exactly four characters for the hex
representation. If it is 32 bits then ``\WXXXXXXXX'' is used using eight
characters of its hex representation. These forms will only be used if UTF8
conversion is not set (see below).

</P>
<P>
Printable characters are normally escaped using the backslash '\'
character. If
<STRONG>ASN1_STRFLGS_ESC_QUOTE</STRONG> 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 ``\XX'' using exactly two characters of the hex
representation.

</P>
<P>
If <STRONG>ASN1_STRFLGS_UTF8_CONVERT</STRONG> is set then characters are converted to UTF8 format first. If the terminal
supports the display of UTF8 sequences then this option will correctly
display multi byte characters.

</P>
<P>
If <STRONG>ASN1_STRFLGS_IGNORE_TYPE</STRONG> 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.

</P>
<P>
If <STRONG>ASN1_STRFLGS_SHOW_TYPE</STRONG> is set then the string type itself is printed out before its value (for
example ``BMPSTRING''), this actually uses <CODE>ASN1_tag2str().</CODE>

</P>
<P>
The content of a string instead of being interpreted can be ``dumped'':
this just outputs the value of the string using the form #XXXX using hex
format for each octet.

</P>
<P>
If <STRONG>ASN1_STRFLGS_DUMP_ALL</STRONG> is set then any type is dumped.

</P>
<P>
Normally non character string types (such as OCTET STRING) are assumed to
be one byte per character, if <STRONG>ASN1_STRFLGS_DUMP_UNKNOWN</STRONG> is set then they will be dumped instead.

</P>
<P>
When a type is dumped normally just the content octets are printed, if 
<STRONG>ASN1_STRFLGS_DUMP_DER</STRONG> is set then the complete encoding is dumped instead (including tag and
length octets).

</P>
<P>
<STRONG>ASN1_STRFLGS_RFC2253</STRONG> includes all the flags required by RFC2253. It is equivalent to:
ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB |
ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN ASN1_STRFLGS_DUMP_DER

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/X509_NAME_print_ex.html#">X509_NAME_print_ex(3)</A>,
<EM>ASN1_tag2str(3)</EM>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
TBA

</P>
:}

