home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl560.zip / t / lib / charnames.t < prev    next >
Text File  |  2000-03-20  |  2KB  |  75 lines

  1. #!./perl
  2.  
  3. BEGIN {
  4.     unless(grep /blib/, @INC) {
  5.     chdir 't' if -d 't';
  6.     unshift @INC, '../lib' if -d '../lib';
  7.     }
  8. }
  9.  
  10. $| = 1;
  11. print "1..12\n";
  12.  
  13. use charnames ':full';
  14.  
  15. print "not " unless "Here\N{EXCLAMATION MARK}?" eq "Here\041?";
  16. print "ok 1\n";
  17.  
  18. {
  19.   use bytes;            # UTEST can switch utf8 on
  20.  
  21.   print "# \$res=$res \$\@='$@'\nnot "
  22.     if $res = eval <<'EOE'
  23. use charnames ":full";
  24. "Here: \N{CYRILLIC SMALL LETTER BE}!";
  25. 1
  26. EOE
  27.       or $@ !~ /above 0xFF/;
  28.   print "ok 2\n";
  29.   # print "# \$res=$res \$\@='$@'\n";
  30.  
  31.   print "# \$res=$res \$\@='$@'\nnot "
  32.     if $res = eval <<'EOE'
  33. use charnames 'cyrillic';
  34. "Here: \N{Be}!";
  35. 1
  36. EOE
  37.       or $@ !~ /CYRILLIC CAPITAL LETTER BE.*above 0xFF/;
  38.   print "ok 3\n";
  39. }
  40.  
  41. # If octal representation of unicode char is \0xyzt, then the utf8 is \3xy\2zt
  42. $encoded_be = "\320\261";
  43. $encoded_alpha = "\316\261";
  44. $encoded_bet = "\327\221";
  45. {
  46.   use charnames ':full';
  47.  
  48.   print "not " unless "\N{CYRILLIC SMALL LETTER BE}" eq $encoded_be;
  49.   print "ok 4\n";
  50.  
  51.   use charnames qw(cyrillic greek :short);
  52.  
  53.   print "not " unless "\N{be},\N{alpha},\N{hebrew:bet}" 
  54.     eq "$encoded_be,$encoded_alpha,$encoded_bet";
  55.   print "ok 5\n";
  56. }
  57.  
  58. {
  59.     use charnames ':full';
  60.     print "not " unless "\x{263a}" eq "\N{WHITE SMILING FACE}";
  61.     print "ok 6\n";
  62.     print "not " unless length("\x{263a}") == 1;
  63.     print "ok 7\n";
  64.     print "not " unless length("\N{WHITE SMILING FACE}") == 1;
  65.     print "ok 8\n";
  66.     print "not " unless sprintf("%vx", "\x{263a}") eq "263a";
  67.     print "ok 9\n";
  68.     print "not " unless sprintf("%vx", "\N{WHITE SMILING FACE}") eq "263a";
  69.     print "ok 10\n";
  70.     print "not " unless sprintf("%vx", "\xFF\N{WHITE SMILING FACE}") eq "ff.263a";
  71.     print "ok 11\n";
  72.     print "not " unless sprintf("%vx", "\x{ff}\N{WHITE SMILING FACE}") eq "ff.263a";
  73.     print "ok 12\n";
  74. }
  75.