Commit | Line | Data |
---|---|---|
423cee85 JH |
1 | #!./perl |
2 | ||
3 | BEGIN { | |
4 | unless(grep /blib/, @INC) { | |
5 | chdir 't' if -d 't'; | |
20822f61 | 6 | @INC = '../lib'; |
423cee85 JH |
7 | } |
8 | } | |
9 | ||
10 | $| = 1; | |
4765795a | 11 | print "1..16\n"; |
423cee85 JH |
12 | |
13 | use charnames ':full'; | |
14 | ||
f70c35af | 15 | print "not " unless "Here\N{EXCLAMATION MARK}?" eq "Here\041?"; |
423cee85 JH |
16 | print "ok 1\n"; |
17 | ||
c82a54e6 | 18 | { |
5d9a6404 | 19 | use bytes; # TEST -utf8 can switch utf8 on |
c82a54e6 IZ |
20 | |
21 | print "# \$res=$res \$\@='$@'\nnot " | |
22 | if $res = eval <<'EOE' | |
423cee85 | 23 | use charnames ":full"; |
4a2d328f | 24 | "Here: \N{CYRILLIC SMALL LETTER BE}!"; |
423cee85 JH |
25 | 1 |
26 | EOE | |
c82a54e6 IZ |
27 | or $@ !~ /above 0xFF/; |
28 | print "ok 2\n"; | |
29 | # print "# \$res=$res \$\@='$@'\n"; | |
423cee85 | 30 | |
c82a54e6 IZ |
31 | print "# \$res=$res \$\@='$@'\nnot " |
32 | if $res = eval <<'EOE' | |
423cee85 | 33 | use charnames 'cyrillic'; |
4a2d328f | 34 | "Here: \N{Be}!"; |
423cee85 JH |
35 | 1 |
36 | EOE | |
c82a54e6 IZ |
37 | or $@ !~ /CYRILLIC CAPITAL LETTER BE.*above 0xFF/; |
38 | print "ok 3\n"; | |
39 | } | |
423cee85 JH |
40 | |
41 | # If octal representation of unicode char is \0xyzt, then the utf8 is \3xy\2zt | |
210db7fc PP |
42 | if (ord('A') == 65) { # as on ASCII or UTF-8 machines |
43 | $encoded_be = "\320\261"; | |
44 | $encoded_alpha = "\316\261"; | |
45 | $encoded_bet = "\327\221"; | |
46 | $encoded_deseng = "\360\220\221\215"; | |
47 | } | |
48 | else { # EBCDIC where UTF-EBCDIC may be used (this may be 1047 specific since | |
49 | # UTF-EBCDIC is codepage specific) | |
50 | $encoded_be = "\270\102\130"; | |
51 | $encoded_alpha = "\264\130"; | |
52 | $encoded_bet = "\270\125\130"; | |
53 | $encoded_deseng = "\336\102\103\124"; | |
54 | } | |
c5cc3500 GS |
55 | |
56 | sub to_bytes { | |
f9a63242 | 57 | pack"a*", shift; |
c5cc3500 GS |
58 | } |
59 | ||
423cee85 JH |
60 | { |
61 | use charnames ':full'; | |
423cee85 | 62 | |
c5cc3500 | 63 | print "not " unless to_bytes("\N{CYRILLIC SMALL LETTER BE}") eq $encoded_be; |
423cee85 JH |
64 | print "ok 4\n"; |
65 | ||
66 | use charnames qw(cyrillic greek :short); | |
67 | ||
c5cc3500 | 68 | print "not " unless to_bytes("\N{be},\N{alpha},\N{hebrew:bet}") |
423cee85 JH |
69 | eq "$encoded_be,$encoded_alpha,$encoded_bet"; |
70 | print "ok 5\n"; | |
71 | } | |
e1992b6d GS |
72 | |
73 | { | |
74 | use charnames ':full'; | |
75 | print "not " unless "\x{263a}" eq "\N{WHITE SMILING FACE}"; | |
76 | print "ok 6\n"; | |
77 | print "not " unless length("\x{263a}") == 1; | |
78 | print "ok 7\n"; | |
79 | print "not " unless length("\N{WHITE SMILING FACE}") == 1; | |
80 | print "ok 8\n"; | |
81 | print "not " unless sprintf("%vx", "\x{263a}") eq "263a"; | |
82 | print "ok 9\n"; | |
83 | print "not " unless sprintf("%vx", "\N{WHITE SMILING FACE}") eq "263a"; | |
84 | print "ok 10\n"; | |
f08d6ad9 GS |
85 | print "not " unless sprintf("%vx", "\xFF\N{WHITE SMILING FACE}") eq "ff.263a"; |
86 | print "ok 11\n"; | |
87 | print "not " unless sprintf("%vx", "\x{ff}\N{WHITE SMILING FACE}") eq "ff.263a"; | |
88 | print "ok 12\n"; | |
e1992b6d | 89 | } |
c00525d4 SP |
90 | |
91 | { | |
92 | use charnames qw(:full); | |
55eda711 | 93 | use utf8; |
c00525d4 SP |
94 | |
95 | my $x = "\x{221b}"; | |
96 | my $named = "\N{CUBE ROOT}"; | |
97 | ||
98 | print "not " unless ord($x) == ord($named); | |
99 | print "ok 13\n"; | |
100 | } | |
101 | ||
f9a63242 JH |
102 | { |
103 | use charnames qw(:full); | |
55eda711 | 104 | use utf8; |
f9a63242 JH |
105 | print "not " unless "\x{100}\N{CENT SIGN}" eq "\x{100}"."\N{CENT SIGN}"; |
106 | print "ok 14\n"; | |
107 | } | |
108 | ||
b896c7a5 A |
109 | { |
110 | use charnames ':full'; | |
111 | ||
112 | print "not " | |
113 | unless to_bytes("\N{DESERET SMALL LETTER ENG}") eq $encoded_deseng; | |
114 | print "ok 15\n"; | |
4765795a | 115 | } |
b896c7a5 | 116 | |
4765795a JH |
117 | { |
118 | # 20001114.001 | |
119 | ||
4c53e876 | 120 | no utf8; # naked Latin-1 |
3ba0e062 | 121 | |
4765795a JH |
122 | if (ord("Ä") == 0xc4) { # Try to do this only on Latin-1. |
123 | use charnames ':full'; | |
124 | my $text = "\N{LATIN CAPITAL LETTER A WITH DIAERESIS}"; | |
125 | print "not " unless $text eq "\xc4" && ord($text) == 0xc4; | |
126 | print "ok 16\n"; | |
127 | } else { | |
128 | print "ok 16 # Skip: not Latin-1\n"; | |
129 | } | |
b896c7a5 A |
130 | } |
131 |