3 print "1..0 # encoding pragma does not support EBCDIC platforms\n";
10 use encoding "latin1"; # ignored (overwritten by the next line)
11 use encoding "greek"; # iso 8859-7 (no "latin" alias, surprise...)
13 # "greek" is "ISO 8859-7", and \xDF in ISO 8859-7 is
14 # \x{3AF} in Unicode (GREEK SMALL LETTER IOTA WITH TONOS),
15 # instead of \xDF in Unicode (LATIN SMALL LETTER SHARP S)
20 print "not " unless ord($a) == 0x3af;
23 print "not " unless ord($b) == 0x100;
30 print "not " unless ord($c) == 0x3af;
33 print "not " unless length($c) == 2;
36 print "not " unless ord(substr($c, 1, 1)) == 0x100;
39 print "not " unless ord(chr(0xdf)) == 0x3af; # spooky
42 print "not " unless ord(pack("C", 0xdf)) == 0x3af;
45 # we didn't break pack/unpack, I hope
47 print "not " unless unpack("C", pack("C", 0xdf)) == 0xdf;
50 # the first octet of UTF-8 encoded 0x3af
51 print "not " unless unpack("C", chr(0xdf)) == 0xce;
54 print "not " unless unpack("U", pack("U", 0xdf)) == 0xdf;
57 print "not " unless unpack("U", chr(0xdf)) == 0x3af;
60 # charnames must still work
61 use charnames ':full';
62 print "not " unless ord("\N{LATIN SMALL LETTER SHARP S}") == 0xdf;
67 $c = "\xDF\N{LATIN SMALL LETTER SHARP S}" . chr(0xdf);
69 print "not " unless ord($c) == 0x3af;
72 print "not " unless ord(substr($c, 1, 1)) == 0xdf;
75 print "not " unless ord(substr($c, 2, 1)) == 0x3af;
80 print "not " unless "\xDF" =~ /\x{3AF}/;
83 print "not " unless "\x{3AF}" =~ /\xDF/;
86 print "not " unless "\xDF" =~ /\xDF/;
89 print "not " unless "\x{3AF}" =~ /\x{3AF}/;
94 my ($byte,$bytes,$U,$Ub,$g1,$g2,$l) = (
95 pack("C*", 0xDF ), # byte
96 pack("C*", 0xDF, 0x20), # ($bytes2 cmp $U) > 0
97 pack("U*", 0x3AF), # $U eq $byte
98 pack("U*", 0xDF ), # $Ub would eq $bytev w/o use encoding
99 pack("U*", 0x3B1), # ($g1 cmp $byte) > 0; === chr(0xe1)
100 pack("U*", 0x3AF, 0x20), # ($g2 cmp $byte) > 0;
101 pack("U*", 0x3AB), # ($l cmp $byte) < 0; === chr(0xdb)
104 # all the tests in this section that compare a byte encoded string
105 # ato UTF-8 encoded are run in all possible vairants
106 # all of the eq, ne, cmp operations tested,
107 # $v z $u tested as well as $u z $v
110 my ($a,$b) = (shift, shift);
111 $a eq $b && $b eq $a &&
112 !( $a ne $b ) && !( $b ne $a ) &&
113 ( $a cmp $b ) == 0 && ( $b cmp $a ) == 0;
117 my ($a,$b) = (shift, shift);
118 $a eq $b || $b eq $a ||
119 !( $a ne $b ) || !( $b ne $a ) ||
120 ( $a cmp $b ) == 0 || ( $b cmp $a ) == 0;
124 my ($a,$b) = (shift, shift);
125 ( $a cmp $b ) == 1 && ( $b cmp $a ) == -1;
127 #match the correct UTF-8 string
128 print "not " unless alleq($byte, $U);
131 #do not match a wrong UTF-8 string
132 print "not " if anyeq($byte, $Ub);
136 print "not " unless allgt ( $g1, $byte ) &&
137 allgt ( $g2, $byte ) &&
138 allgt ( $byte, $l ) &&
139 allgt ( $bytes, $U );
145 $u = $v = $v2 = pack("C*", 0xDF);
146 utf8::upgrade($v); #explicit upgrade
147 $v2 = substr( $v2."\x{410}", 0, -1); #implicit upgrade
149 # implicit upgrade === explicit upgrade
150 print "not " if do{{use bytes; $v ne $v2}} || $v ne $v2;
153 # utf8::upgrade is transparent and does not break equality
154 print "not " unless alleq( $u, $v );
157 $u = $v = pack("C*", 0xDF);
159 #test for a roundtrip, we should get back from where we left
160 eval {utf8::downgrade( $v )};
161 print "not " if $@ !~ /^Wide / || do{{use bytes; $u eq $v}} || $u ne $v;
166 my $byte=pack("C*", 0xDF);
168 print "not " unless pack("U*", 0x3AF) eq $byte;
171 print "not " if chr(0xDF) cmp $byte;
174 print "not " unless ((pack("U*", 0x3B0) cmp $byte) == 1) &&
175 ((pack("U*", 0x3AE) cmp $byte) == -1) &&
176 ((pack("U*", 0x3AF, 0x20) cmp $byte) == 1) &&
177 ((pack("U*", 0x3AF) cmp pack("C*",0xDF,0x20))==-1);
180 # Used to core dump in 5.7.3
181 print ord undef == 0 ? "ok 29\n" : "not ok 29\n";