Re: g_convert and g_utf8_validate



-> > 	I was thinking g_utf8_validate was a response to the fact that
-> > g_convert won't tell you the difference between a failed conversion due to
-> > invalid input, vs. a failed conversion due to an unsupported character
-> > set.
[...]
-> (Or you could actually check errno coming out of g_convert()).

	You cannot use errno because g_convert() calls iconv_open *and*
iconv, and both of those set errno to EINVAL under different
circumstances.

	If you get back from g_convert and errno is set to EINVAL (and
bytes_converted is zero) then you don't know if

1) The iconv_open() failed due to unsupported charset   [...or...]
2) the iconv() failed due to an incomplete multibyte sequence in the
first character of the input

	This is why I thought g_utf8_validate() was meant to check the
(UTF-8) input before passing it to g_convert().


-> If this matters, then g_convert() should just use GError. 

	Well, this was the question that was never answered: Do we want to
require the use of a GError?  Personally, I can see the utility in having
a separate g_charset_is_supported() function to check charsets anyhow (not
to mention something like GList *g_get_supported_charsets() ).  

	This would allow lazy people like me to get away with not using a
GError (which I don't understand).


--Derek





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]