bug-gnu-libiconv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnu-libiconv] iconv(3) return value


From: Bruno Haible
Subject: Re: [bug-gnu-libiconv] iconv(3) return value
Date: Fri, 23 Sep 2011 19:23:17 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Hi,

Jeffrey Walton asked:
> According to 
> http://www.gnu.org/s/libiconv/documentation/libiconv/iconv.3.html:
> 
>   RETURN VALUE
>     The iconv function returns the number of characters converted in a
>     non-reversible way during this call; reversible conversions are not
>     counted. In case of error, it sets errno and returns (size_t)(-1).
> 
> I'm not clear if it is the number of characters in the input buffer,
> or number of characters output buffer?

Don't confuse the concept of "characters" with the concept of "bytes".

The return value is the number of characters that could not be reversibly
converted. For example, if the 'from' character set has a 'MICRO SIGN'
character and the 'to' character set does not have it, but has a
'GREEK SMALL LETTER MU', and iconv() uses that as a replacement,
the conversion from 'MICRO SIGN' to 'GREEK SMALL LETTER MU' would be a
non-reversible conversion. This notion is independent of byte array
sizes.

Bruno
-- 
In memoriam Ghazala Khan <http://en.wikipedia.org/wiki/Ghazala_Khan>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]