Re: UCS-2 in gunicode.h



-> > 1) What is the point of "*bytes_converted", other than to let the
-> > programmer do
[...]
-> >   /* Shouldn't this error-check be inside g_convert()? */
-> 
-> g_print() is probably not the right thing to do on error, the
-> application needs to handle this error, likely by presenting a dialog.

	Sorry, my example was not clear.  The g_print was incidental to
the fact that the only thing *bytes_converted is good for is error
checking.

	My question remains: g_convert() already does g_warnings followed by
a returned NULL when the conversion fails:

[...]
        g_warning ("Conversion from character set `%s' to `%s' is not supported",
from_codeset, to_codeset);
[...]
        g_warning("iconv() failed: %s", strerror (errno)); 
[...]

  if (p == str)
    {     
      g_free (dest);
      return NULL;
    }
[...]
	Since *bytes_converted is only good for error checking, why not
clean up the g_convert() API by removing it, then have the programmer do:

if (outbuf == NULL) {

	do_my_custom_error_handling_such_as_present_a_dialog();

}

	...instead of:

if ( (outbuf == NULL) || (bytes_converted != strlen(inbuf) )  {

	custom_crap();
}


-> Usually people just treat all encodings as gchar*, this seems to be
-> the libc standard.

	Okay, makes sense.

	(Playing the devil's advocate here, I thought "gchar" was supposed
to be an abstract of the internal representation of a character?  What if
glib is ported to some Java-like O.S. where a "char" is 16 bits? And
shouldn't we be using guint8* for UTF-8 input in the g_utf8_*()
functions?)


--Derek






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