Re: g_convert and g_utf8_validate



Derek Simkowiak <dereks@kd-dev.com> writes: 
> 	What is the purpose of g_utf8_validate?  Just to check for invalid
> input before passing to g_convert?
>

g_utf8_validate() assumes the encoding is UTF8. It doesn't work on
anything you'd normally pass to g_convert().

The purpose of this is to ensure you have valid UTF8, for example when
loading a file you expect to be UTF8, or in g_return_if_fail()
statements. If you pass invalid UTF8 to GTK, GTK will probably crash
sooner or later.
 
> 2) If you're going to provide g_utf8_validate, also provide
> g_utf16_validate for completeness.
>

We aren't trying to be complete. We are UTF8 bigots. You have to use
iconv() or g_convert() to use funky charsets.

Havoc




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