[dthorpe@inprise.com] libc/1840: Function result of iconv() is always zero in non-error case.
Bruno Haible
haible@ilog.fr
Tue Aug 1 06:28:00 GMT 2000
Andreas Jäger writes:
> the return value of the iconv
> function in this example is 0. AFAIK this is correct, isn't it?
Yes it is.
> In glibc 2.1.2, iconv() returned the number of bytes written to the
> output buffer, or -1 on error. In glibc 2.1.3, iconv() returns zero
> or -1. The 2.1.2 documentation (in manual/charset.texi) states that
> iconv() is to return the number of conversions performed.
The glibc-2.1.2 implementation and documentation was incorrect. The
new documentation states:
the function returns the number of non-reversible conversions
performed.
> This breaks existing code which used the function result as the indicator of
> the output data length.
This code is incorrect anyway. The right measure how many output bytes
were produced is the amount by which the outbuf pointer was increased
(or, equivalently, the amount by which the outbytesleft value was
decreased) through the iconv() call.
Bruno
More information about the Libc-alpha
mailing list