libtranscript
 All Data Structures Functions Variables Enumerations Enumerator Modules
Data Structures | Functions
Iconv compatible interface.

This interface allows very limited control over the conversion and is only provided for systems without an iconv library. More...

Data Structures

struct  transcript_iconv_t
 An opaque handle representing the transcript_iconv state. More...
 

Functions

size_t transcript_iconv (transcript_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 Perform conversion (iconv compatibility interface). More...
 
int transcript_iconv_close (transcript_iconv_t cd)
 Close a converter (iconv compatibility interface). More...
 
transcript_iconv_t transcript_iconv_open (const char *tocode, const char *fromcode)
 Open a converter (iconv compatibility interface). More...
 

Detailed Description

This interface allows very limited control over the conversion and is only provided for systems without an iconv library.

To make the interface available, define TRANSCRIPT_ICONV_API before including the transcript.h header. If you want the interface to be available without the cc_ prefix, as well, define TRANSCRIPT_ICONV instead.

Function Documentation

size_t transcript_iconv ( transcript_iconv_t  cd,
char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft 
)

Perform conversion (iconv compatibility interface).

Parameters
cdThe conversion state handle to use.
inbufA double pointer to the input buffer.
inbytesleftA pointer to the number of bytes left in the input buffer.
outbufA double pointer to the output buffer.
outbytesleftA pointer to the number of bytes left in the output buffer.
Returns
The number of non-reversible conversions, or (size_t) -1 on failure in which case it sets errno.

When inbuf is not NULL, this function tries to convert the bytes in the input buffer. For each character converted, it updates inbuf, inbytesleft, outbuf and outbytesleft. errno may be set to E2BIG if there is not enough space in outbuf to convert all the bytes, EILSEQ if an illegal sequence is encoutered in inbuf, or EINVAL if the buffer ends with an incomplete sequence.

If inbuf is NULL, the converter is reset to its initial state. If outbuf is not NULL in this case, the converter writes the finishing bytes to the output to ensure a complete and legal conversion.

int transcript_iconv_close ( transcript_iconv_t  cd)

Close a converter (iconv compatibility interface).

Parameters
cdThe conversion state handle to clean up.
Returns
0 on success, -1 on failure (sets errno).
transcript_iconv_t transcript_iconv_open ( const char *  tocode,
const char *  fromcode 
)

Open a converter (iconv compatibility interface).

Parameters
tocodeName of the character set to convert to.
fromcodeName of the character set to convert from.
Returns
A handle for the conversion state, or (transcript_iconv_t) -1 on error. On error, errno is set appropriately.