Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tk label displays escape code instead of Unicode

83 views
Skip to first unread message

Ben Collver

unread,
May 28, 2012, 12:13:30 AM5/28/12
to
In some situations, Tk displays an escape code instead of a Unicode character. Below are two example scripts to demonstrate the problem. This problem happens in Linux on Tk head from around April, but not in Tk 8.5.11.

The script named elip1.tcl has 3 labels:
* three periods
* left arrow
* right arrow

The script named elip2.tcl has 3 labels:
* ellipses character
* left arrow
* right arrow

Both scripts work as expected in Tk 8.5.11.

The elip1.tcl script works as expected in Tk head.

The elip2.tcl script fails in Tk head. It displays an escape code instead of a left arrow. What would cause Tk head to do this?

# rpm -q tk
tk-8.5.11-1.fc16.x86_64

# fossil status
...
checkout: cbc8896878c70ffc43b29964139905975d15ab5a 2012-04-13 19:43:32 UTC

# cat elip1.tcl
set elip "..."
label .elip -text $elip
label .left -text "←"
label .right -text "→"
pack .elip
pack .left
pack .right

# wish elip1.tcl
See http://terrorpin.net/elip/tk85-elip1.jpg

# wish8.6 elip1.tcl
See http://terrorpin.net/elip/tk86-elip1.jpg

# cat elip2.tcl
set elip "…"
label .elip -text $elip
label .left -text "←"
label .right -text "→"
pack .elip
pack .left
pack .right

# wish elip2.tcl
See http://terrorpin.net/elip/tk85-elip2.jpg

# wish8.6 elip2.tcl
See http://terrorpin.net/elip/tk86-elip2.jpg

Gerald W. Lester

unread,
May 28, 2012, 2:21:42 AM5/28/12
to
Works great on OSX in both 8.5 and 8.6.

My guess is that the system encoding on your OS does not support those
characters in the file. Try using the \uxxxx representation instead.
--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+------------------------------------------------------------------------+

tomás zerolo

unread,
May 28, 2012, 3:09:40 AM5/28/12
to
Ben Collver <benco...@gmail.com> writes:

> In some situations, Tk displays an escape code instead of a Unicode character. Below are two example scripts to demonstrate the problem. This problem happens in Linux on Tk head from around April, but not in Tk 8.5.11.
>
> The script named elip1.tcl has 3 labels:
> * three periods
> * left arrow
> * right arrow
>
> The script named elip2.tcl has 3 labels:
> * ellipses character
> * left arrow
> * right arrow
>
> Both scripts work as expected in Tk 8.5.11.

All of them "work for me" -- a fairly standard Debian Wheezy, for

- Tk 8.4 (Debian package 8.4.19-4)
- Tk 8.5 (Debian package 8.5.11-1)
- Tk 8.6 (tk8.6-8.6.0~b2, "hand-backported")

My Xorg is 1:7.6+10.

HTH
-- tomás

Ben Collver

unread,
May 28, 2012, 8:55:43 AM5/28/12
to
I tried \uxxxx representation, but that did not help. Tk head displays all of the characters when I create the labels in the reverse order. It does not matter which order I pack them in. Since it can display all of the labels correctly when the ellipses is not the first character, does that mean that my OS supports those characters?

This one fails:
http://terrorpin.net/elip/elip4.tcl.txt

The failure appears to be the same as the following screen shot:
http://terrorpin.net/elip/tk86-elip2.jpg

This one works:
http://terrorpin.net/elip/elip5.tcl.txt

-Ben

Donal K. Fellows

unread,
May 28, 2012, 11:03:27 AM5/28/12
to
On 28/05/2012 05:13, Ben Collver wrote:
> In some situations, Tk displays an escape code instead of a Unicode
> character. Below are two example scripts to demonstrate the problem.
> This problem happens in Linux on Tk head from around April, but not
> in Tk 8.5.11.
[...]
> Both scripts work as expected in Tk 8.5.11.
>
> The elip1.tcl script works as expected in Tk head.
>
> The elip2.tcl script fails in Tk head. It displays an escape code
> instead of a left arrow. What would cause Tk head to do this?

Differences in font handling is the main suspect. Confirm by rechecking
the scripts with \uXXXX escape codes for the characters so that we can
know for sure that it's not the system encoding or anything irritating
like that.

The main possibility of difference is which font renderer Tk is built
against, i.e., if it is our old internal one versus the newer Xft one.

Donal.

Ben Collver

unread,
May 28, 2012, 11:45:56 AM5/28/12
to
> Differences in font handling is the main suspect. Confirm by rechecking
> the scripts with \uXXXX escape codes for the characters so that we can
> know for sure that it's not the system encoding or anything irritating
> like that.
>
> The main possibility of difference is which font renderer Tk is built
> against, i.e., if it is our old internal one versus the newer Xft one.
>
> Donal.

The scripts with the \uXXXX escape codes are named elip4.tcl and elip5.tcl. I double-checked and verified that these scripts contain only ASCII characters. I configured Tk with --disable-xft. It linked tkUnixFont.c instead of tkUnixRFont.c. I installed this recompiled version of Tk, and that did not help.

-Ben

tomás zerolo

unread,
May 28, 2012, 4:41:24 PM5/28/12
to
Ben Collver <benco...@gmail.com> writes:

> [...] I configured Tk with --disable-xft [...]

On my box, 8.5 and 8.6 are configured with xft. 8.4 doesn't know about
xft, AFAIK.

Regards
-- tomás

Ben Collver

unread,
Jun 9, 2012, 6:28:32 PM6/9/12
to
When I built TK, it could not find libXft. TK fell back to the core fonts, and Fedora does not include a core font for symbols. Once I installed libXft-devel and recompiled TK, the problem went away.

See also:
* http://lists.fedoraproject.org/pipermail/devel/2009-November/040833.html
* http://www.x.org/archive/X11R6.8.2/doc/fonts1.html#2
0 new messages