mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-22 18:22:11 +01:00
gconvert: match GNU iconv behaviour on FreeBSD
FreeBSD iconv by default handles input characters that are not representable in the destination character set by emitting a replacement character such as '?'. While this appears to be the POSIX mandated behaviour it does not match GNU behaviour and causes the gconvert test to fail in the `test_one_half` testcase. Fortunately FreeBSD provides a iconvctl flag to request this behaviour to match GNU iconv. See https://github.com/freebsd/freebsd-src/commit/7c5b23111c5fd199204
This commit is contained in:
parent
143cb92c35
commit
b65cfc9a99
@ -73,8 +73,17 @@ try_conversion (const char *to_codeset,
|
|||||||
|
|
||||||
if (*cd == (iconv_t)-1 && errno == EINVAL)
|
if (*cd == (iconv_t)-1 && errno == EINVAL)
|
||||||
return FALSE;
|
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://github.com/freebsd/freebsd-src/commit/7c5b23111c5fd1992
|
||||||
|
*/
|
||||||
|
int value = 1;
|
||||||
|
if (iconvctl (*cd, ICONV_SET_ILSEQ_INVALID, &value) != 0)
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
x
Reference in New Issue
Block a user