iconv.3c (2010 09)

i
iconv(3C) iconv(3C)
(size_t)BUFSIZ-inbytesleft)) < 0) {
perror("prog");
return BAD;
}
if (!(inbytesleft += bytesread)) {
break; /* end of conversions */
}
ret_val = iconv(cd, &inchar, &inbytesleft,
&outchar, &outbytesleft);
if (write(1, outbuf, (size_t)BUFSIZ-outbytesleft) < 0) {
perror("prog");
return BAD;
}
/* iconv() returns the number of non-identical conversions
* performed. If the entire string in the input buffer is
* converted, the value pointed to by inbytesleft will be
* zero. If the conversion stopped due to any reason, the
* value pointed to by inbytesleft will be non-zero and
* errno is set to indicate the condition.
*/
if ((ret_val == -1) && (errno == EINVAL)) {
/* Input conversion stopped due to an incomplete
* character or shift sequence at the end of the
* input buffer.
*/
/* Copy data left, to the start of buffer */
memcpy((char *)inbuf, (char *)inchar,
(size_t)inbytesleft);
} else if ((ret_val == -1) && (errno == EILSEQ)) {
/* Input conversion stopped due to an input byte
* that does not belong to the input codeset.
*/
error(FATAL, BAD_CONVERSION);
} else if ((ret_val == -1) && (errno == E2BIG)) {
/* Input conversion stopped due to lack of space
* in the output buffer. inbytesleft has the
* number of bytes to be converted.
*/
memcpy((char *)inbuf, (char *)inchar,
(size_t)inbytesleft);
}
/* Go back and read from the input file. */
}
/* end conversion & get rid of the conversion table */
if (iconv_close(cd) == BAD) {
error(FATAL, BAD_CLOSE);
}
return GOOD;
}
WARNINGS
If you use
iconv() and compile/link your application archive on PA-RISC systems, note that iconv()
has a dependency on libdld.sl that will require a change to the compile/link command:
Compile :
cc -Wl,-a,archive -Wl,-E -Wl,+n -l:libdld.sl -o outfile source
Or compile with
CCOPTS and LDOPTS:
4 Hewlett-Packard Company 4 HP-UX 11i Version 3: September 2010