This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [dthorpe@inprise.com] libc/1840: Function result of iconv() is always zero in non-error case.
- To: libc-alpha at sourceware dot cygnus dot com
- Subject: Re: [dthorpe@inprise.com] libc/1840: Function result of iconv() is always zero in non-error case.
- From: Bruno Haible <haible at ilog dot fr>
- Date: Tue, 1 Aug 2000 15:27:59 +0200 (CEST)
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