Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4 |
both |
#include <iconv.h>
iconv_t iconv_open(const char *tocode, const char *fromcode);
Performs all the initialization needed to convert characters from the encoded character set specified in the array pointed to by the fromcode argument to the encoded character set specified in the array pointed to by the tocode argument.
The conversion descriptor relates the two encoded character sets.
For state-dependent encodings, the conversion descriptor will be in an encoded-character-set-dependent initial shift state, ready for immediate use with iconv(). The conversion descriptor remains valid until it is closed with iconv_close().
Settings of fromcode, tocode, and their permitted combinations are implementation-dependent.
There are differences in externals between the iconv() family of functions and Unicode Services. However, these differences will be managed by the iconv() family of functions except where noted in the z/OS XL C/C++ Compiler and Runtime Migration Guide for the Application Programmer. All conversions listed in the topic of the z/OS XL C/C++ Programming Guide entitled “Code Set Converters Supplied” will continue to work as they did prior to the integration of Unicode Services, as long as _ICONV_TECHNIQUE is left undefined. If the application does not define the _ICONV_TECHNIQUE environment variable, iconv_open() uses a default value of LMREC.
Unicode Services supports conversions between thousands of additional character sets not listed in the z/OS XL C/C++ Programming Guide. A complete list of conversions supported by Unicode Services can be found in tables 25 an tables 26 in the z/OS Unicode Services User's Guide and Reference. To set up a conversion using iconv_open() for any of the character sets listed in these tables, the user needs to use a character string representing the CCSID’s for fromcode and tocode. For example, to set up a conversion from CCSID 00256 to CCSID 00870 using conversion technique R, the user would set the _ICONV_TECHNIQUE environment variable to R and call iconv_open() as follows:
cd = iconv_open(“00870”, “00256”);
and continue to use iconv() and iconv_close() as in previous releases.
For illustration of using iconv_close(), see Example.
iconv_open( ) checks for the existence of the environment variable _BIDIATTR to get the bidirectional layout transformation attributes. It will use default values in case _BIDIATTR is not defined, is unset, or in case of the existence of some erroneous values in the _BIDIATTR environment variable. The default values are code set dependent according to the Arabic or Hebrew code set used. For the Arabic 420 code set the default values will be: orientation RTL, type of text visual, shaping shaped, numerals national and swapping on. For the Hebrew 424 code set the default values will be: orientation RTL, type of text visual and swapping on. For the rest of the Arabic code sets the default values will be: orientation RTL, type of text implicit, shaping nominal, numerals national and swapping on.
If successful, iconv_open() returns a conversion descriptor.
A CUN_RS_NO_UNI_ENV error was issued by Unicode Conversion Services.
See z/OS Unicode Services User's Guide and Reference for user action.
A CUN_RS_NO_CONVERSION error was issued by Unicode Conversion Services.
See z/OS Unicode Services User's Guide and Reference for user action.
A CUN_RS_TABLE_NOT_ALIGNED error was issued by Unicode Conversion Services.
See z/OS Unicode Services User's Guide and Reference for user action.
Function iconv() encountered an unexpected error while using Unicode Conversion Services.
Refer to message EDC6258 for additional information.