Tkextlib and Unicode

Hello!

I need to quickly decide if a medium-sized application can be converted
to Ruby. This application has a very sophisticated GUI and needs
extensive Unicode support. As far as I know, the only Ruby GUI library
that supports Unicode is Ruby/Tk. But ... I would also need to use at
least some of the Tk extensions. I'm on Windows XP with the OneClick
Ruby installer 1.8.2-15. I installed ActiveTcl as described in other
posts in this group and edited lib/ruby/1.8/tkextlib/setup.rb to
contain

Tk::AUTO_PATH.list <<= 'c:/tcl/lib'

so at least the BWidgets can be accessed.

Now I tried this code (sorry for mixing various coding stlyes - I was
in a hurry):

require 'tk'
require 'tkextlib/bwidget/combobox.rb'
root = TkRoot.new { title 'Test' }
cb = Tk::BWidget::ComboBox.new(root)
txt = Tk::UTF8_String('\u00E4\u03B1')
cb.configure('values', [txt])
cb.pack
t = TkText.new.pack
t.insert('end', txt);
t.pack
l = TkLabel.new(root) {
text txt
}
l.pack
Tk.mainloop

I get the correct "text" in the text area and the label. But the combo
box seems to show me the raw UTF-8 bytes. Any fix for that? I tried it
various versions of ActiveTcl (8.3, 8.4, 8.5), always with the same
result. But as Tk_VERSION is 8.3 on my system, it's possible that newer
extensions don't get used (as at least ActiveTcl 8.5 seems to install
multiple versions of its components).

Kind regards, ---------------- Axel <><

Message-ID: <1120385246.207588.51970@o13g2000cwo.googlegroups.com>

I get the correct "text" in the text area and the label. But the combo
box seems to show me the raw UTF-8 bytes. Any fix for that?

I'm very sorry. That is a bug on converting from an array of
UTF-8 strings to a Tcl's list string. I'll fix the bug later.

To avoid the problem temporarily, for example, replace the following

···

From: "Axel" <anieden@gmx.de>
Subject: tkextlib and Unicode
Date: Sun, 3 Jul 2005 19:10:45 +0900
-------------------------------------------------------
cb.configure('values', [u_str1, u_str2, ... ])
-------------------------------------------------------
to
-------------------------------------------------------
cb.configure('values',
             Tk::UTF8_String(TkComm.array2tk_list([u_str1, u_str2, ... ])))
-------------------------------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Message-ID: <20050703.224319.74725009.nagai@ai.kyutech.ac.jp>

To avoid the problem temporarily, for example, replace the following

  (snip)

If you use 'UTF-8' and 'ASCII' strings only on your application,
please insert "$KCODE='u'" *BEFORE* "require 'tk'".
Probably, it'll be able to hide your problem also.

···

From: Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Subject: Re: tkextlib and Unicode
Date: Sun, 3 Jul 2005 22:43:21 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Message-ID: <20050703.231712.74724383.nagai@ai.kyutech.ac.jp>

If you use 'UTF-8' and 'ASCII' strings only on your application,
please insert "$KCODE='u'" *BEFORE* "require 'tk'".
Probably, it'll be able to hide your problem also.

Then, probably, you don't need to edit your script to use
"Tk::UTF8_String(TkComm.array2tk_list([u_str1, u_str2, ... ]))".

···

From: Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Subject: Re: tkextlib and Unicode
Date: Sun, 3 Jul 2005 23:17:13 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Hello, Nagai-san!

You are right, adding

$KCODE = 'u'

before requiring Tk also fixes the problem. Thank you very much!