| Top |
void g_mime_iconv_init (void);void g_mime_iconv_shutdown (void);iconv_t g_mime_iconv_open (constchar *to, constchar *from); #define g_mime_iconv (cd,inbuf,inleft,outbuf,outleft)int g_mime_iconv_close (iconv_t cd);
These functions are wrappers around the system iconv(3) routines. The purpose of these wrappers are two-fold:
1. Cache iconv_t descriptors for you in order to optimize opening/closing many descriptors frequently
and
2. To use the appropriate system charset alias for the MIME charset names given as arguments.
void g_mime_iconv_init (void);
Initialize GMime's iconv cache. This *MUST* be called before any gmime-iconv interfaces will work correctly.
Note: this function is called for you by g_mime_init().
void g_mime_iconv_shutdown (void);
Frees internal iconv caches created in g_mime_iconv_init().
Note: this function is called for you by g_mime_shutdown().
iconv_t g_mime_iconv_open (constchar *to, constchar *from);
Allocates a coversion descriptor suitable for converting byte
sequences from charset from to charset to. The resulting
descriptor can be used with iconv()g_mime_iconv() wrapper) any
number of times until closed using g_mime_iconv_close().
See the manual page for iconv_open(3) for further details.
|
charset to convert to |
|
charset to convert from |
Returns : |
a new conversion descriptor for use with g_mime_iconv() on
success or (iconv_t) -1 |
#define g_mime_iconv(cd,inbuf,inleft,outbuf,outleft)
The argument cd must be a conversion descriptor created using the
function g_mime_iconv_open.
The main case is when inbuf is not NULLNULL
The g_mime_iconv function converts one multibyte character at a
time, and for each character conversion it increments *inbuf and
decrements *inleft by the number of converted input bytes, it
increments *outbuf and decrements *outleft by the number of
converted output bytes, and it updates the conversion state
contained in cd. The conversion can stop for four reasons:
1. An invalid multibyte sequence is encountered in the input. In
this case it sets errno to EILSEQ
2. The input byte sequence has been entirely converted, i.e.
*inleft has gone down to 0
3. An incomplete multibyte sequence is encountered in the input,
and the input byte sequence terminates after it. In this case it
sets errno to EINVAL
4. The output buffer has no more room for the next converted
character. In this case it sets errno to E2BIG
A different case is when inbuf is NULLNULLoutbuf is not NULLNULLcd's conversion state to
the initial state and store a corresponding shift sequence at
*outbuf. At most *outleft bytes, starting at *outbuf, will be
written. If the output buffer has no more room for this reset
sequence, it sets errno to E2BIG
A third case is when inbuf is NULLNULLoutbuf is NULLNULLcd's conversion state to the initial
state.
|
iconv_t conversion descriptor |
|
input buffer |
|
number of bytes left in inbuf
|
|
output buffer |
|
number of bytes left in outbuf
|