+#ifdef HAVE_ICONV
+ /* Convert to native character set */
+ if (use_iconv) {
+ size_t inbytes = q - convbuf;
+ size_t outbytes = BUFSIZ;
+ ICONV_CONST char *start = convbuf;
+
+ while (inbytes) {
+ if (iconv(cd, &start, &inbytes, &saveq, &outbytes) ==
+ (size_t)-1) {
+ if (errno != EILSEQ) break;
+ /* character couldn't be converted. we output a `?'
+ * and try to carry on which won't work if
+ * either encoding was stateful */
+ iconv (cd, 0, 0, &saveq, &outbytes);
+ *saveq++ = '?';
+ /* skip to next input character */
+ if (fromutf8) {
+ for (start++;(*start & 192) == 128;start++)
+ inbytes--;
+ } else
+ start++, inbytes--;
+ }
+ }
+ q = saveq;
+ free(convbuf);
+ }
+#endif
+