Skip to main content


rfc2047_utf8_decode — Decode rfc2047 encoding, returning a string that is utf-8 encoded


#include "misc/rfc2047.h"

| char * **rfc2047_utf8_decode** ( | header, |   | |   | hdrlen, |   | |   | outlen, |   | |   | needs_free); |   |

const char * <var class="pdparam">header</var>; int <var class="pdparam">hdrlen</var>; int * <var class="pdparam">outlen</var>; int * <var class="pdparam">needs_free</var>;


Decode rfc2047 encoding, returning a string that is utf-8 encoded.

The needs_free parameter indicates whether or not this function has allocated memory. If this function does allocate memory, it is of the MEMTYPE_MESSAGE_BODY type. For more information about memory types see ec_malloc.


The header to be decoded.


The length of the header in bytes.


If outlen is not NULL, the integer it points to will be updated to hold the length of the returned string.


If needs_free is a NULL pointer, you are always responsible for freeing the returned buffer. Free the returned buffer using ec_free. If needs_free points to an integer, that integer will be set to 1 if the call allocated memory for the returned string (which happens when the header is encoded), but 0 if it did not (which happens when the header is not encoded).

Return Value

If the header needs decoding, this function returns the decoded header.


It is legal to call this function in any thread.

Was this page helpful?