Software Internationalization Guide
POSIX and XPG Internationalization Model
Software Internationalization Guide—526225-002
3-14
Code-Set Conversion Example
Code-Set Conversion Example
This is an example of code-set conversion:
/* Example of code-set conversion*/
#include <stdio.h>
#include <iconv.h>
main()
{
iconv_t cd;
char **inbuf, **outbuf;
size_t *inbytesleft, *outbytesleft;
size_t result;
/* Allocate memory for inbuf, outbuf, inbytesleft and outbytesleft */
cd = iconv_open ("IBM-850", "ISO8859-1");
/* Before calling iconv(), inbuf contains a string of characters for
conversion from one code set to another; inbytesleft indicates the number of
bytes in inbuf; outbytesleft indicates the number of available bytes in
outbuf. */
result = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft);
/* After calling iconv(), outbuf contains the converted data; inbuf pointer,
outbuf pointer, inbytesleft and outbytesleft are updated */
iconv_close(cd);
}