Olaf Leidinger <[EMAIL PROTECTED]> writes:
>
> I'm currently trying to port some of my apps to GTK+-2.0 but I got a
> problem. When trying to create a lable or any other widget with a
> caption that contains german umlauts the text is cutted and only the
> part before that character is displayed. I got a message like this on
> stderr:
>
> ** WARNING **: Invalid UTF8 string passed to pango_layout_set_text()
>
> Okay, I know what's wrong but what can I do to bring these umlauts onto
> my label? I'm not famillar with pango.
Well, you need to convert them to UTF-8. ;-) From Latin-1 that's
really simple. Here is the code:
char*
latin1_to_utf8 (const char *text)
{
GString *str;
const char *p;
str = g_string_new ("");
p = text;
while (*p)
{
g_string_append_unichar (str, *p);
++p;
}
return g_string_free (str, FALSE); /* return str->str and free str */
}
More generally, you could use g_convert() or g_locale_to_utf8() to go
from various encodings to UTF-8. Latin-1 just happens to be easy
because Latin-1 chars have the same values as Unicode chars.
There's a bit of a porting guide in GNOME CVS, you can look at it
here:
http://cvs.gnome.org/lxr/source/porting-doc/
Not sure if it's on the web yet in more readable form. See the
gtk.xml file.
Havoc
_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list