gtk_label_set_text misbehavior ?



Hi all,
I recently discovered a strange behavior with GtkLabel in gtk 1.2.x.
I've been trying to use hi-ascii characters (>127) in GtkLabels, needed in most
languages !=english, but I found the result depends on the machine it's running
on.

On RedHat-based machines, there seems to be no problem. But on debian machines,
if you don't have the correct locale setting (namely LC_CTYPE not set to C or
POSIX), and if your application doesn't do gtk_set_locale(), the GtkLabel's
text will be empty. I don't know about other *nix.

I admit that this can be fixed using locale settings and using
gtk_set_locale(), but feel that being able to fix a problem in the application
doesn't mean the problem doesn't exist in the lib.

Let's be specific: in gtk/gtklabel.c, gtk_label_set_text, one can read:
...
      wc_len = gdk_mbstowcs (str_wc, str, len + 1);
      if (wc_len >= 0)
      {
          str_wc[wc_len] = '\0';
          gtk_label_set_text_internal (label, g_strdup (str), str_wc);
      }

This means that before setting the text of a GtkLabel, gtk tries to convert
the string to a multi-byte string. And if the multi-byte conversion fails, gtk
*gives*up* !!! 
The multi-byte conversion depends both on locale settings and on
USE_NATIVE_LOCALE gtk compilation option, and also on whether the application
has gtk_set_locale or not.

I think this is not the correct behavior and that gtk should use the (1-byte
chars) string in case gdk_mbstowcs fails.

What do you think?

----------------------------------
Eric GAUDET <egaudet intalio com>
Date: 06-Sep-2001    Time: 10:11:01
Constants other than 0 and 1 are
referred to as "magic numbers". 
----------------------------------




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