Tk Source Code

View Ticket
Login
Ticket UUID: 1967075
Title: tk not allowed input nonlatin1 text
Type: Bug Version: obsolete: 8.5.2
Submitter: mmaslano Created on: 2008-05-19 13:12:16
Subsystem: 69. Events Assigned To: jenglish
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2008-06-11 07:18:16
Resolution: None Closed By: jenglish
    Closed on: 2008-06-11 00:18:16
Description:
Reproducer:
1)
LC_ALL=ru_RU.utf8 wish
% encoding system
utf-8
% pack [text .t] -fill both

2) try to type no latin text in text widget

The window stay empty. This is not problem only with Cyrillic, but also other non latin-1 languages like Czech.

Workaround: 
create file ~/.i18n with your locales. Does it mean that wish isn't looking for locales into shell settings?
User Comments: jenglish added on 2008-06-11 07:18:16:
Logged In: YES 
user_id=68433
Originator: NO

@flatworm -- re "Gtk and Qt are immune to this problem" --

Tk uses the low-level XIM facilities built in to libX11.  Gtk and Qt both have their own, independent, toolkit-specific, plugin-based IM infrastructures.  So Gtk (resp Qt) processes keyboard input via a completely different mechanism than Tk does. 

(If you set GTK_IM_MODULE=xim resp QT_IM_MODULE=xim, you should see the same symptoms with Gtk resp Qt apps as you do with Tk apps.  Otherwise, Gtk resp Qt will use whatever IM module is the default for your platform/distro/locale/environment/time of day/phase of moon.)

Anyway, given this:

| ./a.out: locale=ru_RU.utf8
| ./a.out: codeset=UTF-8
| ./a.out: WARNING: X does not support locale ru_RU.utf8
|          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

and this:

| ./a.out: locale=ru_RU.UTF-8
| ./a.out: codeset=UTF-8
| ./a.out: XSupportsLocale => True


it looks like the solution is to use "ru_RU.UTF-8" as the locale, not "ru_RU.utf8".

flatworm added on 2008-06-09 01:00:56:
Logged In: YES 
user_id=1350198
Originator: NO

Running ximinfo.c on Debian Etch with various settings of "broken" locale:

kostix@vangogh:tmp$ gcc -lX11 ximinfo.c

kostix@vangogh:tmp$ locale
LANG=ru_RU.UTF-8
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME=en_US
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES=en_US
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=

kostix@vangogh:tmp$ ./a.out 
./a.out: locale=ru_RU.UTF-8
./a.out: codeset=UTF-8
./a.out: XSupportsLocale => True
./a.out: XServerVendor => The X.Org Foundation
./a.out: XSetLocaleModifiers => 
./a.out: supported style XIMPreeditNone|XIMStatusNone
./a.out: supported style XIMPreeditNothing|XIMStatusNothing

kostix@vangogh:tmp$ LANG=ru_RU.utf8 ./a.out 
./a.out: locale=ru_RU.utf8
./a.out: codeset=UTF-8
./a.out: WARNING: X does not support locale ru_RU.utf8
./a.out: XServerVendor => The X.Org Foundation
./a.out: WARNING: XSetLocaleModifiers failed
./a.out: XOpenIM failed

kostix@vangogh:tmp$ LC_ALL=ru_RU.utf8 ./a.out 
./a.out: locale=ru_RU.utf8
./a.out: codeset=UTF-8
./a.out: WARNING: X does not support locale ru_RU.utf8
./a.out: XServerVendor => The X.Org Foundation
./a.out: WARNING: XSetLocaleModifiers failed
./a.out: XOpenIM failed

kostix@vangogh:tmp$ LC_MESSAGES=ru_RU.utf8 ./a.out 
./a.out: locale=ru_RU.UTF-8
./a.out: codeset=UTF-8
./a.out: XSupportsLocale => True
./a.out: XServerVendor => The X.Org Foundation
./a.out: XSetLocaleModifiers => 
./a.out: supported style XIMPreeditNone|XIMStatusNone
./a.out: supported style XIMPreeditNothing|XIMStatusNothing

kostix@vangogh:tmp$ LC_CTYPE=ru_RU.utf8 ./a.out 
./a.out: locale=ru_RU.utf8
./a.out: codeset=UTF-8
./a.out: WARNING: X does not support locale ru_RU.utf8
./a.out: XServerVendor => The X.Org Foundation
./a.out: WARNING: XSetLocaleModifiers failed
./a.out: XOpenIM failed

flatworm added on 2008-06-09 00:56:08:
Logged In: YES 
user_id=1350198
Originator: NO

Sorry, fat fingers -- I meant "GTK and Qt" as predominant toolkits on today "desktop" Linux distros.

flatworm added on 2008-06-09 00:55:11:
Logged In: YES 
user_id=1350198
Originator: NO

Joe, TK and Qt are immune to this problem -- otherwise RH just would not reintroduce this breakage -- this would be immediately detected by users.

jenglish added on 2008-06-09 00:24:25:
Logged In: YES 
user_id=68433
Originator: NO

Try compiling and running this program:

    http://www.flightlab.com/~joe/repos/ximinfo/ximinfo.c

This might help to diagnose the problem.  Also try it with different LANG or LC_ALL environment settings until you find one that works.

Note that if setting LC_ALL=ru_RU.UTF-8 fixes the problem, you should probably set LC_ALL=ru_RU.UTF-8.

nobody added on 2008-06-07 16:58:11:
Logged In: NO 

ping

jenglish added on 2008-06-07 03:03:46:
Logged In: YES 
user_id=68433
Originator: NO

Probable cause of the problem: glibc (and hence Tcl) and Xlib use slightly different mechanisms to determine the "system" encoding.  It's not uncommon for a particular LANG or LC_CTYPE setting to work with one but not the other.

The only solution I know of is to find a locale setting that works for both, and set LC_CTYPE or LC_ALL to that value (in this case, it looks like ru_RU.UTF-8 works for you.)

The files "locale.alias" and "locale.dir", usually located in /usr/lib/X11/locale, list the locale names that Xlib knows about.

Finding out what locales the C library supports varies from system to system.

[email protected] added on 2008-05-19 22:10:54:
Logged In: NO 

>Workaround:
>create file ~/.i18n with your locales. Does it mean that wish isn't looking
>for locales into shell settings?

It is not correct information.



LC_ALL=ru_RU.utf8 <TK-Program> 

is not work.

but

LC_ALL=ru_RU.UTF-8 <TK-Program> 

work fine


Diffrence in this cases - "UTF-8" or "utf8" charset.

As you can see, tcl works fine in both case:

LC_ALL=ru_RU.utf8 wish
% encoding system
utf-8


LC_ALL=ru_RU.UTF-8 wish
% encoding system
utf-8

But in TK widgets only utf8 charset not work for input text!