Name

iconv_open - allocates descriptor for character set conversion

Library

libc.lib

Synopsis

  #include <iconv.h>
  iconv_t iconv_open (const char *tocode, const char *fromcode);
Sh RETURN VALUES The iconv_open function returns a newly allocated conversion descriptor. In case of error, it sets errno and returns (iconv_t)(-1).

Detailed description

The iconv_open function allocates a conversion descriptor suitable for converting byte sequences from character encoding fromcode to character encoding tocode.

If enough memory is not available in the system to create conversion descriptor, the iconv_open function sets errno.

The character sets permitted for fromcode and tocode are system dependent.

The allocated conversion descriptor can be used with iconv any number of times until it is deallocated using iconv_close.


Examples

#include<stdio.h>
#include<iconv.h>
int main()
{
        iconv_t cd = NULL;
        //Allocate descriptor for charset conversion
        cd = iconv_open("UTF-8", "ISO-8859-1");
        if(cd == (iconv_t) -1)
        {
                printf("Unbale to create a conversion descriptor0);
        }
        else
        {
                printf("Conversion descriptor is created successfully0);
        }
        iconv_close(cd);
        return 0;
}

         

Output Conversion descriptor is created successfully


Errors

EINVAL: The fromcode or tocode charcater set is not supported by the implementation.
ENOMEM: Enough memory is not available to create conversion descriptor.

See also

iconv, iconv_close

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top