Subject: Re: behaviour of iconv in NetBSD and pkgsrc libiconv
To: None <tech-userlevel@NetBSD.org>
From: None <joerg@britannica.bec.de>
List: tech-userlevel
Date: 04/02/2006 18:49:23
On Sun, Apr 02, 2006 at 05:53:06PM +0200, Klaus Heinz wrote:
> This is even mentioned in our man page iconv(3):
>
> "If no conversion exists for a particular character, an
> implementation-defined conversion is performed on this character."
>
> NetBSD's iconv() completes the conversion of the whole buffer and maps
> such characters to a question mark. The return value of iconv() shows
> how many of those non-reversible conversions happened.
> In contrast, converters/libiconv stops the conversion at this point,
> returns an error and gives the application a chance to do something
> about the unconvertible character [1].
The GNU implementation is clearly broken. An implementation defined
conversion is *not* an error. EILSEQ is an absolutely inappropiate error
message, since it doesn't allow to distinguish between invalid input and
valid but unconvertible input.
The correct behaviour to find the first unconvertible character, as sad
as it might seem, is to perform a binary search.
Joerg