Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <iconv.h>
Link against: libc.lib

iconv_open(const char *,const char *)

Interface status: externallyDefinedApi

IMPORT_C iconv_t iconv_open(const char *tocharset, const char *fromcharset);

Description

Allocate memory for codeset conversion descriptor. The iconv_open(const char *,const char *)iconv_open(const char *,const char *) function returns a conversion descriptor that describes a conversion from the codeset specified by the string pointed to by the fromcode argument to the codeset specified by the string pointed to by the tocode argument. For state-dependent encodings, the conversion descriptor will be in a codeset-dependent initial shift state, ready for immediate use with iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *).

Settings of fromcode and tocode and their permitted combinations are implementation-dependent.

A conversion descriptor remains valid in a process until that process closes it.

If a file descriptor is used to implement conversion descriptors, the FD_CLOEXEC flag will be set;

Parameters

const char *tocharset

const char *fromcharset

Return value

iconv_t

Upon successful completion, iconv_open(const char *,const char *)iconv_open(const char *,const char *) returns a conversion descriptor for use on subsequent calls to iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *). Otherwise iconv_open(const char *,const char *)iconv_open(const char *,const char *) returns (iconv_t)-1 and sets errno to indicate the error.

[Top]


iconv(iconv_t,const char **,size_t *,char **,size_t *)

Interface status: externallyDefinedApi

IMPORT_C size_t iconv(iconv_t conversion_descriptor, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);

Description

The iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *) function converts the sequence of characters from one codeset, in the array specified by inbuf, into a sequence of corresponding characters in another codeset, in the array specified by outbuf. The codesets are those specified in the iconv_open(const char *,const char *)iconv_open(const char *,const char *) call that returned the conversion descriptor, cd. The inbuf argument points to a variable that points to the first character in the input buffer and inbytesleft indicates the number of bytes to the end of the buffer to be converted. The outbuf argument points to a variable that points to the first available byte in the output buffer and outbytesleft indicates the number of the available bytes to the end of the buffer.

For state-dependent encodings, the conversion descriptor cd is placed into its initial shift state by a call for which inbuf is a null pointer, or for which inbuf points to a null pointer. When iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *) is called in this way, and if outbuf is not a null pointer or a pointer to a null pointer, and outbytesleft points to a positive value, iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *) will place, into the output buffer, the byte sequence to change the output buffer to its initial shift state. If the output buffer is not large enough to hold the entire reset sequence, iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *) will fail and set errno to [E2BIG]. Subsequent calls with inbuf as other than a null pointer or a pointer to a null pointer cause the conversion to take place from the current state of the conversion descriptor.

If a sequence of input bytes does not form a valid character in the specified codeset, conversion stops after the previous successfully converted character. If the input buffer ends with an incomplete character or shift sequence, conversion stops after the previous successfully converted bytes. If the output buffer is not large enough to hold the entire converted input, conversion stops just prior to the input bytes that would cause the output buffer to overflow. The variable pointed to by inbuf is updated to point to the byte following the last byte successfully used in the conversion. The value pointed to by inbytesleft is decremented to reflect the number of bytes still not converted in the input buffer. The variable pointed to by outbuf is updated to point to the byte following the last byte of converted output data. The value pointed to by outbytesleft is decremented to reflect the number of bytes still available in the output buffer. For state-dependent encodings, the conversion descriptor is updated to reflect the shift state in effect at the end of the last successfully converted byte sequence.

If iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *) encounters a character in the input buffer that is valid, but for which an identical character does not exist in the target codeset, iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *) performs an implementation-dependent conversion on this character.

Parameters

iconv_t conversion_descriptor

const char **inbuf

size_tsize_t *inbytesleft

char **outbuf

size_tsize_t *outbytesleft

Return value

size_tsize_t

The iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *) function updates the variables pointed to by the arguments to reflect the extent of the conversion and returns the number of non-identical conversions performed. If the entire string in the input buffer is converted, the value pointed to by inbytesleft will be 0. If the input conversion is stopped due to any conditions mentioned above, the value pointed to by inbytesleft will be non-zero and errno is set to indicate the condition. If an error occurs iconv(iconv_t,const char **,size_t *,char **,size_t *)iconv(iconv_t,const char **,size_t *,char **,size_t *) returns (size_t)-1 and sets errno to indicate the error.

[Top]


iconv_close(iconv_t)

Interface status: externallyDefinedApi

IMPORT_C int iconv_close(iconv_t conversion_descriptor);

Description

The iconv_close(iconv_t)iconv_close(iconv_t) function deallocates the conversion descriptor cd and all other associated resources allocated by iconv_open(const char *,const char *)iconv_open(const char *,const char *).

If a file descriptor is used to implement the type iconv_t, that file descriptor will be closed.

Parameters

iconv_t conversion_descriptor

Return value

int

Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error.