Re: Display Japanese Characters in GtkComboBox





On Sun, Apr 26, 2009 at 4:10 PM, Peter E Dennis <peter edwin dennis gmail com> wrote:
Hi,

I am retrieving japanese characters from a MySQL database and trying
to display them in a combo box.

At the moment I am setting up my model using:

my $liststore = Gtk2::ListStore->new('Glib::Int', 'Glib::String',
'Glib::String');

But the characters all appear mainly as small squares with numbers in
each of the corners; in other words not the japanese characters that I
can see when simply querying the table through mysql-client.
You get this strange squares because your strings don't seem to be having valid UTF-8 characters. Gtk2 is expecting to get UTF-8 strings and what has been provided doesn't seem to be too valid. Your perl strings are probably not valid UTF-8. This can happen if the mysql driver fails to return proper UTF-8 data. If you know the encoding of the database then decode each string to UTF-8 as soon as you read them from the mysql database.

use Encode;
$string = decode("iso-8859-1", $octets); # NOTE replace iso-8859-1 by your database's actual encoding



Is there a different data type that I can use so that these characters
are displayed?

Or is this a font issue?
You can rule out if it's a font issue by copy pasting a valid japanese character into a gtk application (gedit). If you can see the character then it's probably not a font issue.


My OS is Ubuntu 8.04.

Thanks for any suggestions.

Peter.

I hope that it will help.

--
Emmanuel Rodriguez


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