Hi Greg,

Greg Eck wrote:
I am looking for a critical answer in a design issue.
I want to use the Tkx subset to program a gui, but need to verify that Tkx will indeed display my foreign characters (Mongolian, Tibetan, Chinese).

Tkx (via Tcl/Tk) can properly display all unicode chars in the BMP (basic multilingual plane).

I can see the good utf8 characters being processed in output, but not as displayed in the listbox. Could you verify that this is true or false, bug or deficiency, maybe my lack of knowing the correct syntax? If you could tell me what I need to do in this code snippet to display the $v variable, then I will go ahead and press ahead. If you view the file with Arial Unicode MS or some other pan-Unicode font, you should be able to see the $v variable fine.

I've attached a modified version that adds one more line that does display correctly. Note I use direct unicode code points. I'm not sure whether it is the utf8() or the special marker starting your file that is throwing off the translation. In any case, this shows that it is possible and one way to do it.

Jeff
use Unicode::String qw(utf8 latin1 utf16be);
use Tkx;
use warnings;

my $mw = Tkx::widget->new(".");
$mw->g_wm_title("GreySon");
$mw->g_wm_minsize(300,200);
$u = utf8("hello1");
$v = utf8("жишээ");
$w = utf8("hello3");
$x = "\x{0436}\x{0438}\x{0448}\x{044d}\x{044d}";
print "$u $v $x howdy ... \n";

my $message = "The $v hen lives in a chicken coop.";
print $message . "\n";
my @colors = ($u, $v, $w, $x);

my $label = $mw->new_label(-textvariable => \$message);
my $enter = $mw->new_label(-text => "Select correct word");
my $lb = $mw->new_listbox(-selectmode => "single");
$lb->insert("end", @colors);
my $show = $mw->new_button(-text => "Show selection", -command => \&display);
my $exit = $mw->new_button(-text => "Exit", -command => sub {exit});

$label->g_pack;
$enter->g_pack;
$lb->g_pack;
$show->g_pack;
$exit->g_pack;

Tkx::MainLoop();

Tkx::bind($mw, "<<Copy>>", sub { $lb->get($lb->curselection); });

sub display {
    my @selections = $lb->curselection;
    $message = "You selected: ";
    foreach (@selections) {$message .= $lb->get($_);}
}

Reply via email to