diff --git a/glib/gconvert.c b/glib/gconvert.c index 4eaabc278..e7c222f8d 100644 --- a/glib/gconvert.c +++ b/glib/gconvert.c @@ -73,8 +73,17 @@ try_conversion (const char *to_codeset, if (*cd == (iconv_t)-1 && errno == EINVAL) return FALSE; - else - return TRUE; + +#if defined(__FreeBSD__) && defined(ICONV_SET_ILSEQ_INVALID) + /* On FreeBSD request GNU iconv compatible handling of characters that cannot + * be repesented in the destination character set. + * See https://cgit.freebsd.org/src/commit/?id=7c5b23111c5fd1992047922d4247c4a1ce1bb6c3 + */ + int value = 1; + if (iconvctl (*cd, ICONV_SET_ILSEQ_INVALID, &value) != 0) + return FALSE; +#endif + return TRUE; } static gboolean