iconv_open(3) — Subroutines
NAME
iconv_open − Opens a character codeset converter
LIBRARY
The iconv library (libiconv.a)
SYNOPSIS
#include <iconv.h>
iconv_t iconv_open(
const char ∗tocode,
const char ∗fromcode);
PARAMETERS
tocodeSpecifies the destination codeset
fromcodeSpecifies the originating codeset
DESCRIPTION
The iconv_open() function initializes codeset converters. These codeset converters are used by the iconv function to convert characters from one codeset to another. The iconv_open() function finds the converter that performs the character codeset conversion specified by the fromcode and tocode parameters, initializes that converter, then returns a conversion descriptor of type iconv_t that identifies the codeset converter.
The iconv_open() function first searches for an algorithmic converter. If it does not find an algorithmic converter for the specified codesets, the function then searches for a table converter. The algorithmic and table converter file names are formed by concatenating the tocode parameter codeset name onto the fromcode parameter codeset name, with an underscore between the two, for example:
fromcode tocode Algorithmic or Table Converter
ct ISO8859-1 ct_ISO8859-1
The iconv_open() function searches for an algorithmic converter in an iconv subdirectory in a directory specified in the LOCPATH environment variable. The function searches for a table converter in an iconvTable subdirectory in a directory specified in the LOCPATH environment variable. If LOCPATH is not defined, iconv_open() uses the default value: /usr/lib/nls/loc.
RETURN VALUES
If successful, the function returns a converter descriptor. Otherwise, the function returns -1 cast to iconv_t and sets the errno global variable to indicate the error.
ERRORS
If any of the following conditions occur, the iconv_open() function sets errno to the corresponding value.
[EMFILE]Specifies that the number of file descriptors specified by the OPEN_MAX configuration variable is currently open in the calling process.
[ENAMETOOLONG]
A path used to find the codeset converter or the converter table is longer than PATH_MAX.
[ENFILE]Specifies that too many files are currently open in the system.
[ENOMEM]Specifies that insufficient storage space is available.
[EINVAL]Specifies that the conversion specified by the fromcode and tocode parameters is not supported by the implementation.
RELATED INFORMATION
Commands: genxlt(1), iconv(1).
Functions: iconv(3), iconv_close(3).