home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _1e0503bb5ea464353da19c5f97a6b1e9 < prev    next >
Text File  |  2004-06-01  |  3KB  |  65 lines

  1. # unicodeout.pl
  2.  
  3. use vars qw/$TOP/;
  4. use subs qw/unicodeadd/;
  5.  
  6. sub unicodeout {
  7.  
  8.     # This demonstration script shows how you can produce output (in label
  9.     # widgets) using many different alphabets.
  10.  
  11.     my($demo) = @_;
  12.     $TOP = $MW->WidgetDemo(
  13.         -name     => $demo,
  14.         -text     => 'This is a sample of Perl/Tk\'s support for languages that use non-Western character sets.  However, what you will actually seebelow depends largely on what character sets you have installed, and what you see for characters that are not present varies greatly between platforms as well.  The strings are written in Perl Unicode characters using the \\x{XXXX} escape sequence so as to do so in a portable fashion.',
  15.         -title    => 'Unicode Label Demonstration',
  16.         -iconname => 'unicodeout',
  17.     );
  18.  
  19.     my $unicode_wait = $TOP->Label(
  20.         -text => 'Please wait while loading fonts...',
  21.         -font => 'Helvetica 12 italic',
  22.     )->pack;
  23.     $TOP->update;
  24.  
  25.     # Processing when some characters are missing might take a while, so make
  26.     # sure we're displaying something in the meantime.
  27.  
  28.     $TOP->Busy;
  29.  
  30.     unicodeadd $TOP, 'Arabic',
  31.     "\x{FE94}\x{FEF4}\x{FE91}\x{FEAE}\x{FECC}\x{FEDF}\x{FE8D}\x{FE94}\x{FEE4}\x{FEE0}\x{FEDC}\x{FEDF}\x{FE8D}";
  32.     unicodeadd $TOP, "Trad. Chinese", "\x{4E2D}\x{570B}\x{7684}\x{6F22}\x{5B57}";
  33.     unicodeadd $TOP, "Simpl. Chinese", "\x{6C49}\x{8BED}";
  34.     unicodeadd $TOP, 'Greek', 
  35.     "\x{0395}\x{03BB}\x{03BB}\x{03B7}\x{03BD}\x{03B9}\x{03BA}\x{03AE}\x{03B3}\x{03BB}\x{03CE}\x{03C3}\x{03C3}\x{03B1}";
  36.     unicodeadd $TOP, 'Hebrew', 
  37.     "\x{05DD}\x{05D9}\x{05DC}\x{05E9}\x{05D5}\x{05E8}\x{05D9}\x{05DC}\x{05D9}\x{05D0}\x{05E8}\x{05E9}\x{05D9}";
  38.     unicodeadd $TOP, 'Japanese', 
  39.     "\x{65E5}\x{672C}\x{8A9E}\x{306E}\x{3072}\x{3089}\x{304C}\x{306A}\x{6F22}\x{5B57}\x{3068}\x{30AB}\x{30BF}\x{30AB}\x{30CA}";
  40.     unicodeadd $TOP, 'Korean',
  41.     "\x{B300}\x{D55C}\x{BBFC}\x{AD6D}\x{C758}\x{D55C}\x{AE00}";
  42.     unicodeadd $TOP, 'Russian', 
  43.     "\x{0420}\x{0443}\x{0441}\x{0441}\x{043A}\x{0438}\x{0439}\x{044F}\x{0437}\x{044B}\x{043A}";
  44.  
  45.     # We're done processing, so change things back to normal running.
  46.  
  47.     $unicode_wait->destroy;
  48.     $TOP->Unbusy;
  49.  
  50. } # end unicodeout
  51.  
  52. sub unicodeadd {
  53.  
  54.     my ($w, $language, @args) = @_;
  55.  
  56.     my $sample = join('', @args);
  57.     my $l1 = $w->Label(-text => "$language: ", qw/-anchor nw -pady 0/);
  58.     my $l2 = $w->Label(-text => $sample, qw/-anchor nw -width 30 -pady 0/);
  59.     $l1->grid($l1, $l2, qw/-sticky ew -pady 0/);
  60.     $l1->gridConfigure(qw/-padx 1m/);
  61.  
  62. } # end unicodeadd
  63.  
  64. 1;
  65.