| 1 | #!./perl
|
|---|
| 2 |
|
|---|
| 3 | my @WARN;
|
|---|
| 4 |
|
|---|
| 5 | BEGIN {
|
|---|
| 6 | unless(grep /blib/, @INC) {
|
|---|
| 7 | chdir 't' if -d 't';
|
|---|
| 8 | @INC = '../lib';
|
|---|
| 9 | require './test.pl';
|
|---|
| 10 | }
|
|---|
| 11 | $SIG{__WARN__} = sub { push @WARN, @_ };
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | require File::Spec;
|
|---|
| 15 |
|
|---|
| 16 | $| = 1;
|
|---|
| 17 |
|
|---|
| 18 | print "1..74\n";
|
|---|
| 19 |
|
|---|
| 20 | use charnames ':full';
|
|---|
| 21 |
|
|---|
| 22 | print "not " unless "Here\N{EXCLAMATION MARK}?" eq "Here!?";
|
|---|
| 23 | print "ok 1\n";
|
|---|
| 24 |
|
|---|
| 25 | {
|
|---|
| 26 | use bytes; # TEST -utf8 can switch utf8 on
|
|---|
| 27 |
|
|---|
| 28 | print "# \$res=$res \$\@='$@'\nnot "
|
|---|
| 29 | if $res = eval <<'EOE'
|
|---|
| 30 | use charnames ":full";
|
|---|
| 31 | "Here: \N{CYRILLIC SMALL LETTER BE}!";
|
|---|
| 32 | 1
|
|---|
| 33 | EOE
|
|---|
| 34 | or $@ !~ /above 0xFF/;
|
|---|
| 35 | print "ok 2\n";
|
|---|
| 36 | # print "# \$res=$res \$\@='$@'\n";
|
|---|
| 37 |
|
|---|
| 38 | print "# \$res=$res \$\@='$@'\nnot "
|
|---|
| 39 | if $res = eval <<'EOE'
|
|---|
| 40 | use charnames 'cyrillic';
|
|---|
| 41 | "Here: \N{Be}!";
|
|---|
| 42 | 1
|
|---|
| 43 | EOE
|
|---|
| 44 | or $@ !~ /CYRILLIC CAPITAL LETTER BE.*above 0xFF/;
|
|---|
| 45 | print "ok 3\n";
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | # If octal representation of unicode char is \0xyzt, then the utf8 is \3xy\2zt
|
|---|
| 49 | if (ord('A') == 65) { # as on ASCII or UTF-8 machines
|
|---|
| 50 | $encoded_be = "\320\261";
|
|---|
| 51 | $encoded_alpha = "\316\261";
|
|---|
| 52 | $encoded_bet = "\327\221";
|
|---|
| 53 | $encoded_deseng = "\360\220\221\215";
|
|---|
| 54 | }
|
|---|
| 55 | else { # EBCDIC where UTF-EBCDIC may be used (this may be 1047 specific since
|
|---|
| 56 | # UTF-EBCDIC is codepage specific)
|
|---|
| 57 | $encoded_be = "\270\102\130";
|
|---|
| 58 | $encoded_alpha = "\264\130";
|
|---|
| 59 | $encoded_bet = "\270\125\130";
|
|---|
| 60 | $encoded_deseng = "\336\102\103\124";
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | sub to_bytes {
|
|---|
| 64 | pack"a*", shift;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | {
|
|---|
| 68 | use charnames ':full';
|
|---|
| 69 |
|
|---|
| 70 | print "not " unless to_bytes("\N{CYRILLIC SMALL LETTER BE}") eq $encoded_be;
|
|---|
| 71 | print "ok 4\n";
|
|---|
| 72 |
|
|---|
| 73 | use charnames qw(cyrillic greek :short);
|
|---|
| 74 |
|
|---|
| 75 | print "not " unless to_bytes("\N{be},\N{alpha},\N{hebrew:bet}")
|
|---|
| 76 | eq "$encoded_be,$encoded_alpha,$encoded_bet";
|
|---|
| 77 | print "ok 5\n";
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | {
|
|---|
| 81 | use charnames ':full';
|
|---|
| 82 | print "not " unless "\x{263a}" eq "\N{WHITE SMILING FACE}";
|
|---|
| 83 | print "ok 6\n";
|
|---|
| 84 | print "not " unless length("\x{263a}") == 1;
|
|---|
| 85 | print "ok 7\n";
|
|---|
| 86 | print "not " unless length("\N{WHITE SMILING FACE}") == 1;
|
|---|
| 87 | print "ok 8\n";
|
|---|
| 88 | print "not " unless sprintf("%vx", "\x{263a}") eq "263a";
|
|---|
| 89 | print "ok 9\n";
|
|---|
| 90 | print "not " unless sprintf("%vx", "\N{WHITE SMILING FACE}") eq "263a";
|
|---|
| 91 | print "ok 10\n";
|
|---|
| 92 | print "not " unless sprintf("%vx", "\xFF\N{WHITE SMILING FACE}") eq "ff.263a";
|
|---|
| 93 | print "ok 11\n";
|
|---|
| 94 | print "not " unless sprintf("%vx", "\x{ff}\N{WHITE SMILING FACE}") eq "ff.263a";
|
|---|
| 95 | print "ok 12\n";
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | {
|
|---|
| 99 | use charnames qw(:full);
|
|---|
| 100 | use utf8;
|
|---|
| 101 |
|
|---|
| 102 | my $x = "\x{221b}";
|
|---|
| 103 | my $named = "\N{CUBE ROOT}";
|
|---|
| 104 |
|
|---|
| 105 | print "not " unless ord($x) == ord($named);
|
|---|
| 106 | print "ok 13\n";
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | {
|
|---|
| 110 | use charnames qw(:full);
|
|---|
| 111 | use utf8;
|
|---|
| 112 | print "not " unless "\x{100}\N{CENT SIGN}" eq "\x{100}"."\N{CENT SIGN}";
|
|---|
| 113 | print "ok 14\n";
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | {
|
|---|
| 117 | use charnames ':full';
|
|---|
| 118 |
|
|---|
| 119 | print "not "
|
|---|
| 120 | unless to_bytes("\N{DESERET SMALL LETTER ENG}") eq $encoded_deseng;
|
|---|
| 121 | print "ok 15\n";
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | {
|
|---|
| 125 | # 20001114.001
|
|---|
| 126 |
|
|---|
| 127 | no utf8; # naked Latin-1
|
|---|
| 128 |
|
|---|
| 129 | if (ord("Ä") == 0xc4) { # Try to do this only on Latin-1.
|
|---|
| 130 | use charnames ':full';
|
|---|
| 131 | my $text = "\N{LATIN CAPITAL LETTER A WITH DIAERESIS}";
|
|---|
| 132 | print "not " unless $text eq "\xc4" && ord($text) == 0xc4;
|
|---|
| 133 | print "ok 16\n";
|
|---|
| 134 | } else {
|
|---|
| 135 | print "ok 16 # Skip: not Latin-1\n";
|
|---|
| 136 | }
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | {
|
|---|
| 140 | print "not " unless charnames::viacode(0x1234) eq "ETHIOPIC SYLLABLE SEE";
|
|---|
| 141 | print "ok 17\n";
|
|---|
| 142 |
|
|---|
| 143 | # Unused Hebrew.
|
|---|
| 144 | print "not " if defined charnames::viacode(0x0590);
|
|---|
| 145 | print "ok 18\n";
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | {
|
|---|
| 149 | print "not " unless
|
|---|
| 150 | sprintf("%04X", charnames::vianame("GOTHIC LETTER AHSA")) eq "10330";
|
|---|
| 151 | print "ok 19\n";
|
|---|
| 152 |
|
|---|
| 153 | print "not " if
|
|---|
| 154 | defined charnames::vianame("NONE SUCH");
|
|---|
| 155 | print "ok 20\n";
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | {
|
|---|
| 159 | # check that caching at least hasn't broken anything
|
|---|
| 160 |
|
|---|
| 161 | print "not " unless charnames::viacode(0x1234) eq "ETHIOPIC SYLLABLE SEE";
|
|---|
| 162 | print "ok 21\n";
|
|---|
| 163 |
|
|---|
| 164 | print "not " unless
|
|---|
| 165 | sprintf("%04X", charnames::vianame("GOTHIC LETTER AHSA")) eq "10330";
|
|---|
| 166 | print "ok 22\n";
|
|---|
| 167 |
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | print "not " unless "\N{CHARACTER TABULATION}" eq "\t";
|
|---|
| 171 | print "ok 23\n";
|
|---|
| 172 |
|
|---|
| 173 | print "not " unless "\N{ESCAPE}" eq "\e";
|
|---|
| 174 | print "ok 24\n";
|
|---|
| 175 |
|
|---|
| 176 | print "not " unless "\N{NULL}" eq "\c@";
|
|---|
| 177 | print "ok 25\n";
|
|---|
| 178 |
|
|---|
| 179 | if ($^O eq 'MacOS')
|
|---|
| 180 | {
|
|---|
| 181 | print "not " unless "\N{CARRIAGE RETURN (CR)}" eq "\n";
|
|---|
| 182 | print "ok 26\n";
|
|---|
| 183 |
|
|---|
| 184 | print "not " unless "\N{CARRIAGE RETURN}" eq "\n";
|
|---|
| 185 | print "ok 27\n";
|
|---|
| 186 |
|
|---|
| 187 | print "not " unless "\N{CR}" eq "\n";
|
|---|
| 188 | print "ok 28\n";
|
|---|
| 189 | }
|
|---|
| 190 | else
|
|---|
| 191 | {
|
|---|
| 192 | print "not " unless "\N{LINE FEED (LF)}" eq "\n";
|
|---|
| 193 | print "ok 26\n";
|
|---|
| 194 |
|
|---|
| 195 | print "not " unless "\N{LINE FEED}" eq "\n";
|
|---|
| 196 | print "ok 27\n";
|
|---|
| 197 |
|
|---|
| 198 | print "not " unless "\N{LF}" eq "\n";
|
|---|
| 199 | print "ok 28\n";
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | my $nel = ord("A") == 193 ? qr/^(?:\x15|\x25)$/ : qr/^\x85$/;
|
|---|
| 203 |
|
|---|
| 204 | print "not " unless "\N{NEXT LINE (NEL)}" =~ $nel;
|
|---|
| 205 | print "ok 29\n";
|
|---|
| 206 |
|
|---|
| 207 | print "not " unless "\N{NEXT LINE}" =~ $nel;
|
|---|
| 208 | print "ok 30\n";
|
|---|
| 209 |
|
|---|
| 210 | print "not " unless "\N{NEL}" =~ $nel;
|
|---|
| 211 | print "ok 31\n";
|
|---|
| 212 |
|
|---|
| 213 | print "not " unless "\N{BYTE ORDER MARK}" eq chr(0xFEFF);
|
|---|
| 214 | print "ok 32\n";
|
|---|
| 215 |
|
|---|
|
|---|