in reply to umlauts in Tk widgets
The default font seems to be using a latin-1 mapping.use Encode; use Tk; my $bytes = "öäü"; my $text = decode("utf-8", $bytes); my $mw = MainWindow->new; $mw->Label(-text => encode("iso-8859-1", $text))->pack; MainLoop;
How "öäü" is represented will depend on your text editing environment. Mine happens to be UTF-8. Alternatively I could have used use utf8; instead of decode().
Update: The encoding to iso-8859-1 is not necessary. Tk seems to be one of the very few external modules which is text-aware (yeah!). Both of these invocations will produce the same result:
$mw->Label(-text => encode("iso-8859-1", $text))->pack; $mw->Label(-text => $text)->pack;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: umlauts in Tk widgets
by Kardan (Initiate) on Jul 16, 2008 at 17:38 UTC |