On Mon, Apr 27, 2026 at 07:12:23AM +0800, Kevin J. McCarthy wrote:
> /* Test against macOS 14.4 bug: Failures are not distinguishable from
> successful returns.
> POSIX:2018 says: "The iconv() function shall ... return the number of
> non-identical conversions performed."
> But here, the conversion always does transliteration (the suffixes
> "//TRANSLIT" and "//IGNORE" have no effect, nor does iconvctl()) and
> does not report when it does a non-identical conversion. */
> {
> iconv_t cd_utf8_to_88591 = iconv_open ("ISO-8859-1", "UTF-8");
> if (cd_utf8_to_88591 != (iconv_t)(-1))
> {
> static ICONV_CONST char input[] = "\305\202"; /* LATIN SMALL LETTER L
> WITH STROKE */
> char buf[10];
> ICONV_CONST char *inptr = input;
> size_t inbytesleft = strlen (input);
> char *outptr = buf;
> size_t outbytesleft = sizeof (buf);
> size_t res = iconv (cd_utf8_to_88591,
> &inptr, &inbytesleft,
> &outptr, &outbytesleft);
> /* Here:
> With glibc, GNU libiconv (including macOS up to 13): res ==
> (size_t)-1, errno == EILSEQ.
> With musl libc, NetBSD 10, Solaris 11: res == 1.
> With macOS 14.4: res == 0, output is "l". */
> if (res == 0)
> result |= 2;
> iconv_close (cd_utf8_to_88591);
> }
> }
>
> My guess is that this is failing on MacOS now. It's not surprising, I
> guess. Mutt already has an open ticket about MacOS buggy iconv:
> https://gitlab.com/muttmua/mutt/-/work_items/504#note_2982482398
>
> You could try installing libiconv and using the --with-libiconv-prefix. See
That works, but GNU libiconv lacks support for UTF-8-MAC. You have to
patch the support in manually. Homebrew does this, for example, as
follows.
<https://raw.githubusercontent.com/Homebrew/patches/9be2793af/libiconv/patch-utf8mac.diff>
It's feasible, but not really convenient.
Here are the relevant files from Apple's libiconv for reference.
<https://github.com/apple-oss-distributions/libiconv/tree/libiconv-115.100.1/libiconv_modules/UTF8MAC>
Dennis