Character Table



I was wondering if someone could help me figure out how to display characters
in a label widget.  I was trying to build a character table to add symbols
and other characters to a document in a program I was building.  I have
spent quite a few hours to no avail.   Basically, I have a table that I want
to add buttons with labels displaying a character, so the user can choose
the character that they wish to use.  I have been able to generate the
characters, but the g_utf8_validate function recognizes most of them as
invalid(except the ASCII charaters).  I figure that I am screwing up the
encoding somehow.  I am new to c and I would appreciate any help.

Here is the code:
	int n, r, c;
	r=0;
	c=0;
	for(n=32; n<1000; n++)
 	{
		static gchar buf[8];
		g_sprintf(buf, "%c", n);
		printf("string:%s", buf);

 		gchar *end;
		if(g_utf8_validate (buf,  -1, &end))
		{
			g_print(" added\n");
			if (strcmp(buf, ""))
			{
 				GtkWidget *btnChar;
 				btnChar = gtk_button_new_with_label (buf);

 				gtk_table_attach_defaults   (tableSymbol,
 					     btnChar,
 					     c,
 					     c+1,
 					     r,
 					     r+1);
				c += 1;
				if (c > 10)
				{
					c = 0;
					r += 1;
				}
 				gtk_widget_show(btnChar);
			}
		}
		else
		{
			g_print(" invalid\n");
		}
	}
--
View this message in context: http://www.nabble.com/Character-Table-t1214436.html#a3211774
Sent from the Gtk+ - Dev - General forum at Nabble.com.




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