I don't know whether the MS-Windows (binary?) distributions of Tk are different from those for unix (source code), but whenever I've installed Tk for5.8.x from source code (via CPAN), the test phase of the installation has generally included a succesful text display of Japanese (and Chinese) characters. Here is the snippet that runs the display of Japanese in a text widget -- slightly modified so I could run it from the command line via "perl -e ..." (and use a larger font size):
use Tk;
use Tk::widgets qw(Text);
my $mw = MainWindow->new;
$mw->geometry("+10+10");
#my $font = 'Times';
my $font = 'fixed';
my $t = $mw->Scrolled(Text => -font => [$font => 24, 'normal'])->pa
+ck( -fill => 'both', -expand => 1);
$file = "t/JP.dat";
open(my $fh,"<:utf8",$file) || die "Cannot open $file:$!";
while (<$fh>)
{
# s/[^ -~\s]/?/g;
$t->insert('end',$_);
$t->see('end');
$mw->update;
}
close($fh);
MainLoop;
I won't repeat the whole content of "JP.dat", which is used by this script -- you can get that yourself from the source code tarball if you don't have it already. It's just a long list of utf8 code points, arranged 16 characters per line. Here are the first few lines:
0x0020: ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = >
0x0040: @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^
0x0060: ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
0x8ea0: 。 「 」 、 ・ ヲ ァ ィ ゥ ェ ォ ャ ュ ョ ッ
+ ー ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ
0x8ec0: タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ �‹ フ ヘ
+ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ �› ワ ン ゙
(There's genuine utf8 character data in that "code" block -- if it looks garbled, be sure to set your browser for utf8 encoding. Also, if your PM user settings impose wrapping on code lines, this could disrupt a character or two -- that'll go away when you use the "download code" link; it appears that the PM code-wrapping process is not utf8-aware...)
You may need to play with the font specs a bit to make it legible, or you may need to install a suitable font (sorry, I can't help with that).
Oh, and this is supposed to be perl 5.8.0 or greater, to get the ":<utf8" in the open statement to be properly understood. (I was doing it with 5.8.1 on macosx.) |