<refentry id="gmime-gmime-utils">
<refmeta>
<refentrytitle role="top_of_page" id="gmime-gmime-utils.top_of_page">gmime-utils</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>
  GMIME Library
</refmiscinfo>
</refmeta>
<refnamediv>
<refname>gmime-utils</refname>
<refpurpose>MIME utility functions</refpurpose>
</refnamediv>

<refsynopsisdiv id="gmime-gmime-utils.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>                    <link linkend="GMimeReferences">GMimeReferences</link>;
<link linkend="time-t"><returnvalue>time_t</returnvalue></link>              <link linkend="g-mime-utils-header-decode-date">g_mime_utils_header_decode_date</link>     (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>,
                                                         <parameter><link linkend="int"><type>int</type></link> *tz_offset</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-header-format-date">g_mime_utils_header_format_date</link>     (<parameter><link linkend="time-t"><type>time_t</type></link> date</parameter>,
                                                         <parameter><link linkend="int"><type>int</type></link> tz_offset</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-generate-message-id">g_mime_utils_generate_message_id</link>    (<parameter>const <link linkend="char"><type>char</type></link> *fqdn</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-decode-message-id">g_mime_utils_decode_message_id</link>      (<parameter>const <link linkend="char"><type>char</type></link> *message_id</parameter>);
const <link linkend="char"><returnvalue>char</returnvalue></link> *        <link linkend="g-mime-references-get-message-id">g_mime_references_get_message_id</link>    (<parameter>const <link linkend="GMimeReferences"><type>GMimeReferences</type></link> *ref</parameter>);
const <link linkend="GMimeReferences"><returnvalue>GMimeReferences</returnvalue></link> * <link linkend="g-mime-references-get-next">g_mime_references_get_next</link>      (<parameter>const <link linkend="GMimeReferences"><type>GMimeReferences</type></link> *ref</parameter>);
<link linkend="GMimeReferences"><returnvalue>GMimeReferences</returnvalue></link> *   <link linkend="g-mime-references-decode">g_mime_references_decode</link>            (<parameter>const <link linkend="char"><type>char</type></link> *text</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="g-mime-references-append">g_mime_references_append</link>            (<parameter><link linkend="GMimeReferences"><type>GMimeReferences</type></link> **refs</parameter>,
                                                         <parameter>const <link linkend="char"><type>char</type></link> *msgid</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="g-mime-references-clear">g_mime_references_clear</link>             (<parameter><link linkend="GMimeReferences"><type>GMimeReferences</type></link> **refs</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="g-mime-references-free">g_mime_references_free</link>              (<parameter><link linkend="GMimeReferences"><type>GMimeReferences</type></link> *refs</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-header-fold">g_mime_utils_header_fold</link>            (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-header-printf">g_mime_utils_header_printf</link>          (<parameter>const <link linkend="char"><type>char</type></link> *format</parameter>,
                                                         <parameter>...</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-quote-string">g_mime_utils_quote_string</link>           (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>);
<link linkend="void"><returnvalue>void</returnvalue></link>                <link linkend="g-mime-utils-unquote-string">g_mime_utils_unquote_string</link>         (<parameter><link linkend="char"><type>char</type></link> *str</parameter>);
<link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>            <link linkend="g-mime-utils-text-is-8bit">g_mime_utils_text_is_8bit</link>           (<parameter>unsigned <link linkend="char"><type>char</type></link> *text</parameter>,
                                                         <parameter><link linkend="size-t"><type>size_t</type></link> len</parameter>);
<link linkend="GMimeContentEncoding"><returnvalue>GMimeContentEncoding</returnvalue></link>  <link linkend="g-mime-utils-best-encoding">g_mime_utils_best_encoding</link>        (<parameter>unsigned <link linkend="char"><type>char</type></link> *text</parameter>,
                                                         <parameter><link linkend="size-t"><type>size_t</type></link> len</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-decode-8bit">g_mime_utils_decode_8bit</link>            (<parameter>const <link linkend="char"><type>char</type></link> *text</parameter>,
                                                         <parameter><link linkend="size-t"><type>size_t</type></link> len</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-header-decode-text">g_mime_utils_header_decode_text</link>     (<parameter>const <link linkend="char"><type>char</type></link> *text</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-header-encode-text">g_mime_utils_header_encode_text</link>     (<parameter>const <link linkend="char"><type>char</type></link> *text</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-header-decode-phrase">g_mime_utils_header_decode_phrase</link>   (<parameter>const <link linkend="char"><type>char</type></link> *phrase</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-header-encode-phrase">g_mime_utils_header_encode_phrase</link>   (<parameter>const <link linkend="char"><type>char</type></link> *phrase</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-structured-header-fold">g_mime_utils_structured_header_fold</link> (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>);
<link linkend="char"><returnvalue>char</returnvalue></link> *              <link linkend="g-mime-utils-unstructured-header-fold">g_mime_utils_unstructured_header_fold</link>
                                                        (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>);
</synopsis>
</refsynopsisdiv>

<refsect1 id="gmime-gmime-utils.description" role="desc">
<title role="desc.title">Description</title>
<para>
Utility functions to parse, encode and decode various MIME tokens
and encodings.
</para>
</refsect1>
<refsect1 id="gmime-gmime-utils.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GMimeReferences" role="struct">
<title>GMimeReferences</title>
<indexterm zone="GMimeReferences"><primary>GMimeReferences</primary></indexterm>
<programlisting>typedef struct {
	GMimeReferences *next;
	char *msgid;
} GMimeReferences;
</programlisting>
<para>
A List of references, as per the References or In-Reply-To header
fields.
</para><variablelist role="struct">
<varlistentry><term><link linkend="GMimeReferences"><type>GMimeReferences</type></link>&#160;*<structfield id="GMimeReferences.next">next</structfield>;</term>
<listitem><simpara>Pointer to the next reference.
</simpara></listitem>
</varlistentry>
<varlistentry><term><link linkend="char"><type>char</type></link>&#160;*<structfield id="GMimeReferences.msgid">msgid</structfield>;</term>
<listitem><simpara>Reference message-id.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-header-decode-date" role="function">
<title>g_mime_utils_header_decode_date ()</title>
<indexterm zone="g-mime-utils-header-decode-date"><primary>g_mime_utils_header_decode_date</primary></indexterm>
<programlisting><link linkend="time-t"><returnvalue>time_t</returnvalue></link>              g_mime_utils_header_decode_date     (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>,
                                                         <parameter><link linkend="int"><type>int</type></link> *tz_offset</parameter>);</programlisting>
<para>
Decodes the rfc822 date string and saves the GMT offset into
<parameter>tz_offset</parameter> if non-NULL.
</para><variablelist role="params">
<varlistentry><term><parameter>str</parameter>&#160;:</term>
<listitem><simpara>input date string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>tz_offset</parameter>&#160;:</term>
<listitem><simpara>timezone offset
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the time_t representation of the date string specified by
<parameter>str</parameter> or (time_t) <link linkend="0:CAPS"><literal>0</literal></link> on error. If <parameter>tz_offset</parameter> is non-NULL, the value
of the timezone offset will be stored.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-header-format-date" role="function">
<title>g_mime_utils_header_format_date ()</title>
<indexterm zone="g-mime-utils-header-format-date"><primary>g_mime_utils_header_format_date</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_header_format_date     (<parameter><link linkend="time-t"><type>time_t</type></link> date</parameter>,
                                                         <parameter><link linkend="int"><type>int</type></link> tz_offset</parameter>);</programlisting>
<para>
Allocates a string buffer containing the rfc822 formatted date
string represented by <parameter>time</parameter> and <parameter>tz_offset</parameter>.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>time_t date representation
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>tz_offset</parameter>&#160;:</term>
<listitem><simpara>Timezone offset
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a valid string representation of the date.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-generate-message-id" role="function">
<title>g_mime_utils_generate_message_id ()</title>
<indexterm zone="g-mime-utils-generate-message-id"><primary>g_mime_utils_generate_message_id</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_generate_message_id    (<parameter>const <link linkend="char"><type>char</type></link> *fqdn</parameter>);</programlisting>
<para>
Generates a unique Message-Id.
</para><variablelist role="params">
<varlistentry><term><parameter>fqdn</parameter>&#160;:</term>
<listitem><simpara>Fully qualified domain name
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a unique string in an addr-spec format suitable for use as
a Message-Id.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-decode-message-id" role="function">
<title>g_mime_utils_decode_message_id ()</title>
<indexterm zone="g-mime-utils-decode-message-id"><primary>g_mime_utils_decode_message_id</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_decode_message_id      (<parameter>const <link linkend="char"><type>char</type></link> *message_id</parameter>);</programlisting>
<para>
Decodes a msg-id as defined by rfc822.
</para><variablelist role="params">
<varlistentry><term><parameter>message_id</parameter>&#160;:</term>
<listitem><simpara>string containing a message-id
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the addr-spec portion of the msg-id.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-references-get-message-id" role="function">
<title>g_mime_references_get_message_id ()</title>
<indexterm zone="g-mime-references-get-message-id"><primary>g_mime_references_get_message_id</primary></indexterm>
<programlisting>const <link linkend="char"><returnvalue>char</returnvalue></link> *        g_mime_references_get_message_id    (<parameter>const <link linkend="GMimeReferences"><type>GMimeReferences</type></link> *ref</parameter>);</programlisting>
<para>
Gets the Message-Id reference from the <link linkend="GMimeReferences"><type>GMimeReferences</type></link> node.
</para><variablelist role="params">
<varlistentry><term><parameter>ref</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GMimeReferences"><type>GMimeReferences</type></link> list
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the Message-Id reference from the <link linkend="GMimeReferences"><type>GMimeReferences</type></link> node.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-references-get-next" role="function">
<title>g_mime_references_get_next ()</title>
<indexterm zone="g-mime-references-get-next"><primary>g_mime_references_get_next</primary></indexterm>
<programlisting>const <link linkend="GMimeReferences"><returnvalue>GMimeReferences</returnvalue></link> * g_mime_references_get_next      (<parameter>const <link linkend="GMimeReferences"><type>GMimeReferences</type></link> *ref</parameter>);</programlisting>
<para>
Advances to the next reference node in the <link linkend="GMimeReferences"><type>GMimeReferences</type></link> list.
</para><variablelist role="params">
<varlistentry><term><parameter>ref</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GMimeReferences"><type>GMimeReferences</type></link> list
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the next reference node in the <link linkend="GMimeReferences"><type>GMimeReferences</type></link> list.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-references-decode" role="function">
<title>g_mime_references_decode ()</title>
<indexterm zone="g-mime-references-decode"><primary>g_mime_references_decode</primary></indexterm>
<programlisting><link linkend="GMimeReferences"><returnvalue>GMimeReferences</returnvalue></link> *   g_mime_references_decode            (<parameter>const <link linkend="char"><type>char</type></link> *text</parameter>);</programlisting>
<para>
Decodes a list of msg-ids as in the References and/or In-Reply-To
headers defined in rfc822.
</para><variablelist role="params">
<varlistentry><term><parameter>text</parameter>&#160;:</term>
<listitem><simpara>string containing a list of msg-ids
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a list of referenced msg-ids.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-references-append" role="function">
<title>g_mime_references_append ()</title>
<indexterm zone="g-mime-references-append"><primary>g_mime_references_append</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                g_mime_references_append            (<parameter><link linkend="GMimeReferences"><type>GMimeReferences</type></link> **refs</parameter>,
                                                         <parameter>const <link linkend="char"><type>char</type></link> *msgid</parameter>);</programlisting>
<para>
Appends a reference to msgid to the list of references.
</para><variablelist role="params">
<varlistentry><term><parameter>refs</parameter>&#160;:</term>
<listitem><simpara>the address of a <link linkend="GMimeReferences"><type>GMimeReferences</type></link> list
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>msgid</parameter>&#160;:</term>
<listitem><simpara>a message-id string
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-references-clear" role="function">
<title>g_mime_references_clear ()</title>
<indexterm zone="g-mime-references-clear"><primary>g_mime_references_clear</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                g_mime_references_clear             (<parameter><link linkend="GMimeReferences"><type>GMimeReferences</type></link> **refs</parameter>);</programlisting>
<para>
Clears the <link linkend="GMimeReferences"><type>GMimeReferences</type></link> list and resets it to <link linkend="NULL:CAPS"><literal>NULL</literal></link>.
</para><variablelist role="params">
<varlistentry><term><parameter>refs</parameter>&#160;:</term>
<listitem><simpara>address of a <link linkend="GMimeReferences"><type>GMimeReferences</type></link> list
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-references-free" role="function">
<title>g_mime_references_free ()</title>
<indexterm zone="g-mime-references-free"><primary>g_mime_references_free</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                g_mime_references_free              (<parameter><link linkend="GMimeReferences"><type>GMimeReferences</type></link> *refs</parameter>);</programlisting>
<para>
Frees the <link linkend="GMimeReferences"><type>GMimeReferences</type></link> list.
</para><variablelist role="params">
<varlistentry><term><parameter>refs</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GMimeReferences"><type>GMimeReferences</type></link> list
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-header-fold" role="function">
<title>g_mime_utils_header_fold ()</title>
<indexterm zone="g-mime-utils-header-fold"><primary>g_mime_utils_header_fold</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_header_fold            (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>);</programlisting>
<para>
Folds a structured header according to the rules in rfc822.
</para><variablelist role="params">
<varlistentry><term><parameter>str</parameter>&#160;:</term>
<listitem><simpara>input string
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> an allocated string containing the folded header.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-header-printf" role="function">
<title>g_mime_utils_header_printf ()</title>
<indexterm zone="g-mime-utils-header-printf"><primary>g_mime_utils_header_printf</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_header_printf          (<parameter>const <link linkend="char"><type>char</type></link> *format</parameter>,
                                                         <parameter>...</parameter>);</programlisting>
<para>
Allocates a buffer containing a formatted header specified by the
<parameter>Varargs</parameter>.
</para><variablelist role="params">
<varlistentry><term><parameter>format</parameter>&#160;:</term>
<listitem><simpara>string format
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>arguments
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> an allocated string containing the folded header specified
by <parameter>format</parameter> and the following arguments.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-quote-string" role="function">
<title>g_mime_utils_quote_string ()</title>
<indexterm zone="g-mime-utils-quote-string"><primary>g_mime_utils_quote_string</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_quote_string           (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>);</programlisting>
<para>
Quotes <parameter>string</parameter> as needed according to the rules in rfc2045.
</para><variablelist role="params">
<varlistentry><term><parameter>str</parameter>&#160;:</term>
<listitem><simpara>input string
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> an allocated string containing the escaped and quoted (if
needed to be) input string. The decision to quote the string is
based on whether or not the input string contains any 'tspecials'
as defined by rfc2045.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-unquote-string" role="function">
<title>g_mime_utils_unquote_string ()</title>
<indexterm zone="g-mime-utils-unquote-string"><primary>g_mime_utils_unquote_string</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link>                g_mime_utils_unquote_string         (<parameter><link linkend="char"><type>char</type></link> *str</parameter>);</programlisting>
<para>
Unquotes and unescapes a string.
</para><variablelist role="params">
<varlistentry><term><parameter>str</parameter>&#160;:</term>
<listitem><simpara>input string
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-text-is-8bit" role="function">
<title>g_mime_utils_text_is_8bit ()</title>
<indexterm zone="g-mime-utils-text-is-8bit"><primary>g_mime_utils_text_is_8bit</primary></indexterm>
<programlisting><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>            g_mime_utils_text_is_8bit           (<parameter>unsigned <link linkend="char"><type>char</type></link> *text</parameter>,
                                                         <parameter><link linkend="size-t"><type>size_t</type></link> len</parameter>);</programlisting>
<para>
Determines if <parameter>text</parameter> contains 8bit characters within the first <parameter>len</parameter>
bytes.
</para><variablelist role="params">
<varlistentry><term><parameter>text</parameter>&#160;:</term>
<listitem><simpara>text to check for 8bit chars
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>len</parameter>&#160;:</term>
<listitem><simpara>text length
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the text contains 8bit characters or <link linkend="FALSE:CAPS"><literal>FALSE</literal></link>
otherwise.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-best-encoding" role="function">
<title>g_mime_utils_best_encoding ()</title>
<indexterm zone="g-mime-utils-best-encoding"><primary>g_mime_utils_best_encoding</primary></indexterm>
<programlisting><link linkend="GMimeContentEncoding"><returnvalue>GMimeContentEncoding</returnvalue></link>  g_mime_utils_best_encoding        (<parameter>unsigned <link linkend="char"><type>char</type></link> *text</parameter>,
                                                         <parameter><link linkend="size-t"><type>size_t</type></link> len</parameter>);</programlisting>
<para>
Determines the best content encoding for the first <parameter>len</parameter> bytes of
<parameter>text</parameter>.
</para><variablelist role="params">
<varlistentry><term><parameter>text</parameter>&#160;:</term>
<listitem><simpara>text to encode
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>len</parameter>&#160;:</term>
<listitem><simpara>text length
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GMimeContentEncoding"><type>GMimeContentEncoding</type></link> that is determined to be the best
encoding type for the specified block of text. ("best" in this
particular case means smallest output size)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-decode-8bit" role="function">
<title>g_mime_utils_decode_8bit ()</title>
<indexterm zone="g-mime-utils-decode-8bit"><primary>g_mime_utils_decode_8bit</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_decode_8bit            (<parameter>const <link linkend="char"><type>char</type></link> *text</parameter>,
                                                         <parameter><link linkend="size-t"><type>size_t</type></link> len</parameter>);</programlisting>
<para>
Attempts to convert text in an unknown 8bit/multibyte charset into
UTF-8 by finding the charset which will convert the most bytes into
valid UTF-8 characters as possible. If no exact match can be found,
it will choose the best match and convert invalid byte sequences
into question-marks (?) in the returned string buffer.
</para><variablelist role="params">
<varlistentry><term><parameter>text</parameter>&#160;:</term>
<listitem><simpara>input text in unknown 8bit/multibyte character set
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>len</parameter>&#160;:</term>
<listitem><simpara>input text length
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a UTF-8 string representation of <parameter>text</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-header-decode-text" role="function">
<title>g_mime_utils_header_decode_text ()</title>
<indexterm zone="g-mime-utils-header-decode-text"><primary>g_mime_utils_header_decode_text</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_header_decode_text     (<parameter>const <link linkend="char"><type>char</type></link> *text</parameter>);</programlisting>
<para>
Decodes an rfc2047 encoded 'text' header.
</para>
<para>
Note: See <link linkend="g-mime-set-user-charsets"><function>g_mime_set_user_charsets()</function></link> for details on how charset
conversion is handled for unencoded 8bit text and/or wrongly
specified rfc2047 encoded-word tokens.
</para><variablelist role="params">
<varlistentry><term><parameter>text</parameter>&#160;:</term>
<listitem><simpara>header text to decode
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a newly allocated UTF-8 string representing the the decoded
header.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-header-encode-text" role="function">
<title>g_mime_utils_header_encode_text ()</title>
<indexterm zone="g-mime-utils-header-encode-text"><primary>g_mime_utils_header_encode_text</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_header_encode_text     (<parameter>const <link linkend="char"><type>char</type></link> *text</parameter>);</programlisting>
<para>
Encodes a 'text' header according to the rules in rfc2047.
</para><variablelist role="params">
<varlistentry><term><parameter>text</parameter>&#160;:</term>
<listitem><simpara>text to encode
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the encoded header. Useful for encoding
headers like "Subject".
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-header-decode-phrase" role="function">
<title>g_mime_utils_header_decode_phrase ()</title>
<indexterm zone="g-mime-utils-header-decode-phrase"><primary>g_mime_utils_header_decode_phrase</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_header_decode_phrase   (<parameter>const <link linkend="char"><type>char</type></link> *phrase</parameter>);</programlisting>
<para>
Decodes an rfc2047 encoded 'phrase' header.
</para>
<para>
Note: See <link linkend="g-mime-set-user-charsets"><function>g_mime_set_user_charsets()</function></link> for details on how charset
conversion is handled for unencoded 8bit text and/or wrongly
specified rfc2047 encoded-word tokens.
</para><variablelist role="params">
<varlistentry><term><parameter>phrase</parameter>&#160;:</term>
<listitem><simpara>header to decode
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a newly allocated UTF-8 string representing the the decoded
header.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-header-encode-phrase" role="function">
<title>g_mime_utils_header_encode_phrase ()</title>
<indexterm zone="g-mime-utils-header-encode-phrase"><primary>g_mime_utils_header_encode_phrase</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_header_encode_phrase   (<parameter>const <link linkend="char"><type>char</type></link> *phrase</parameter>);</programlisting>
<para>
Encodes a 'phrase' header according to the rules in rfc2047.
</para><variablelist role="params">
<varlistentry><term><parameter>phrase</parameter>&#160;:</term>
<listitem><simpara>phrase to encode
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the encoded 'phrase'. Useful for encoding internet
addresses.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-structured-header-fold" role="function">
<title>g_mime_utils_structured_header_fold ()</title>
<indexterm zone="g-mime-utils-structured-header-fold"><primary>g_mime_utils_structured_header_fold</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_structured_header_fold (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>);</programlisting>
<para>
Folds a structured header according to the rules in rfc822.
</para><variablelist role="params">
<varlistentry><term><parameter>str</parameter>&#160;:</term>
<listitem><simpara>input string
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> an allocated string containing the folded header.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-mime-utils-unstructured-header-fold" role="function">
<title>g_mime_utils_unstructured_header_fold ()</title>
<indexterm zone="g-mime-utils-unstructured-header-fold"><primary>g_mime_utils_unstructured_header_fold</primary></indexterm>
<programlisting><link linkend="char"><returnvalue>char</returnvalue></link> *              g_mime_utils_unstructured_header_fold
                                                        (<parameter>const <link linkend="char"><type>char</type></link> *str</parameter>);</programlisting>
<para>
Folds an unstructured header according to the rules in rfc822.
</para><variablelist role="params">
<varlistentry><term><parameter>str</parameter>&#160;:</term>
<listitem><simpara>input string
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> an allocated string containing the folded header.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>

</refentry>
