Re: help with text wrapping on a GtkTreeView and displaying non US chars
- From: Havoc Pennington <hp redhat com>
- To: Ramsés Morales <ramses computer org>
- Cc: gtk-list gnome org, gtk-app-devel-list gnome org
- Subject: Re: help with text wrapping on a GtkTreeView and displaying non US chars
- Date: 03 Mar 2002 12:29:21 -0500
Ramsés Morales <ramses computer org> writes:
I want to display ISO-8859-1 characters on a text cell on a GtkTreeView.
I'm getting this error:
Invalid UTF8 string passed to pango_layout_set_text()
The text gets cut where the first character with an accent should
appear.
I tried the g_locale_to_UTF8, but it cuts the text before it ends even
if it is plain US characters.
It would also only work in Latin-1 locales if you passed in a
hardcoded Latin-1 string to this function.
I tried this:
gtk_tree_store_set(model, &comment_iter, 6, comment->id, 7,
g_locale_to_utf8(comment->comment, -1, NULL, NULL, NULL), -1);
If you get the error from g_locale_to_utf8 instead of passing NULL for
the error field, it may give you informative information. See the
GError docs. Also the above is a memleak (as you probably know, I
understand it's test code).
How can I display european characters?
Convert them to UTF-8. Here is the code:
static 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);
}
This takes advantage of the fact that Latin-1 characters are a subset
of Unicode characters. (But the Latin-1 encoding is not a subset of
the UTF-8 encoding.)
You might put a bug in bugzilla to add the above function to the
"Common Questions" section of the reference manual.
Also, I want the comment to wrap around a fixed column width, instead of
having the column grow. I tried changing properties on the text cell
renderer and the tree view column, but no luck.
How can I do that??
This feature is not implemented yet, I don't think. There should be a
bug in bugzilla if you want to get on the CC list to track progress,
or if not please add such a bug.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]