Open System Services Library Calls Reference Manual (G06.27+, H06.04+)

OSS Library Calls (i - m) iconv_open(3)
NAME
iconv_open - Opens a character code-set converter
LIBRARY
G-series native OSS processes: /G/system/sysnn/zicnvsrl
H-series OSS processes: /G/system/zdllnnn/zicnvdll
SYNOPSIS
#include <iconv.h>
iconv_t iconv_open(
const char *tocode,
const char *fromcode);
PARAMETERS
tocode Species the destination code set.
fromcode Species the originating code set.
DESCRIPTION
The iconv_open() function initializes code-set converters. These code set converters are used by
the iconv() function to convert characters from one code set to another. The iconv_open() func-
tion nds the converter that performs the character code-set conversion specied by the from-
code and tocode parameters, initializes that converter, then returns a conversion descriptor of
type iconv_t that identies the code-set converter.
The iconv_open() function rst searches for a code set converter. If it does not nd a converter
for the specied code sets, it searches for a conversion table. The converter and conversion table
lenames are formed by concatenating the tocode parameter code-set name onto the fromcode
parameter code-set name, with an underscore between the two, for example:
fromcode tocode Converter or Conversion table le
ct ISO8859-1 ct_ISO8859-1
The iconv_open() function searches for the converter in an iconv subdirectory in a directory
specied in the LOCPATH environment variable. If it cannot nd a converter, it uses a table-
driven converter and it searches for a conversion table in an iconvTable subdirectory in a direc-
tory specied in the LOCPATH environment variable. If LOCPATH is not dened,
iconv_open() uses the default value: /usr/lib/nls/loc.
RETURN VALUES
A conversion descriptor is returned if successful. Otherwise -1 cast to iconv_t is returned, and
errno is set to indicate the error.
ERRORS
If any of the following conditions occur, the iconv_open() function sets errno to the correspond-
ing value.
[EMFILE] Species that the number of le descriptors specied by the OPEN_MAX
conguration variable is currently open in the calling process.
[ENAMETOOLONG]
A path used to nd the code-set converter or the converter table is longer than
PATH_MAX.
527187-004 Hewlett-Packard Company 45