X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=charset.c;h=18e9cdc5e74cf63ed0622a4512bab99648a15a04;hp=19c3a2b5440c579ab0898a9f608803d29c0b1a7b;hb=0c528da3f6976cfef3d729d9cd66bd8f265a4060;hpb=6833ce8bdca2d64e14485118f2a4417b7e1cb1b1 diff --git a/charset.c b/charset.c index 19c3a2b..18e9cdc 100644 --- a/charset.c +++ b/charset.c @@ -379,18 +379,24 @@ size_t mutt_iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft, if (*t) continue; } - if (outrepl) + /* Replace the output */ + if (!outrepl) + outrepl = "?"; + iconv (cd, 0, 0, &ob, &obl); + if (obl) { - /* Try replacing the output */ int n = strlen (outrepl); - if (n <= obl) + if (n > obl) { - memcpy (ob, outrepl, n); - ++ib, --ibl; - ob += n, obl -= n; - ++ret; - continue; + outrepl = "?"; + n = 1; } + memcpy (ob, outrepl, n); + ++ib, --ibl; + ob += n, obl -= n; + ++ret; + iconv (cd, 0, 0, 0, 0); /* for good measure */ + continue; } } *inbuf = ib, *inbytesleft = ibl;