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.)


In reply to Re: Displaying Kana by graff
in thread Displaying Kana by Trag

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.