More diagnostics from Nicholas Clark.
[p5sagit/p5-mst-13.2.git] / lib / encoding.t
CommitLineData
a72c7584 1print "1..19\n";
0a378802 2
0effba8c 3BEGIN {
4 if (ord("A") == 193) {
5 print "1..0 # encoding pragma does not support EBCDIC platforms\n";
6 }
7}
8
0a378802 9use encoding "latin1"; # ignored (overwritten by the next line)
f14ed3c6 10use encoding "greek"; # iso 8859-7 (no "latin" alias, surprise...)
0a378802 11
0a378802 12# "greek" is "ISO 8859-7", and \xDF in ISO 8859-7 is
f14ed3c6 13# \x{3AF} in Unicode (GREEK SMALL LETTER IOTA WITH TONOS),
0a378802 14# instead of \xDF in Unicode (LATIN SMALL LETTER SHARP S)
15
9f4817db 16$a = "\xDF";
17$b = "\x{100}";
18
19print "not " unless ord($a) == 0x3af;
0a378802 20print "ok 1\n";
21
9f4817db 22print "not " unless ord($b) == 0x100;
0a378802 23print "ok 2\n";
24
9f4817db 25my $c;
26
27$c = $a . $b;
28
29print "not " unless ord($c) == 0x3af;
0a378802 30print "ok 3\n";
31
9f4817db 32print "not " unless length($c) == 2;
33print "ok 4\n";
34
35print "not " unless ord(substr($c, 1, 1)) == 0x100;
36print "ok 5\n";
0a378802 37
121910a4 38print "not " unless ord(chr(0xdf)) == 0x3af; # spooky
39print "ok 6\n";
40
41print "not " unless ord(pack("C", 0xdf)) == 0x3af;
42print "ok 7\n";
43
44# we didn't break pack/unpack, I hope
45
46print "not " unless unpack("C", pack("C", 0xdf)) == 0xdf;
47print "ok 8\n";
48
49# the first octet of UTF-8 encoded 0x3af
50print "not " unless unpack("C", chr(0xdf)) == 0xce;
51print "ok 9\n";
bfa383d6 52
3de8ed06 53print "not " unless unpack("U", pack("U", 0xdf)) == 0xdf;
54print "ok 10\n";
55
56print "not " unless unpack("U", chr(0xdf)) == 0x3af;
57print "ok 11\n";
58
bfa383d6 59# charnames must still work
60use charnames ':full';
61print "not " unless ord("\N{LATIN SMALL LETTER SHARP S}") == 0xdf;
3de8ed06 62print "ok 12\n";
63
64# combine
65
66$c = "\xDF\N{LATIN SMALL LETTER SHARP S}" . chr(0xdf);
67
68print "not " unless ord($c) == 0x3af;
69print "ok 13\n";
70
71print "not " unless ord(substr($c, 1, 1)) == 0xdf;
72print "ok 14\n";
73
74print "not " unless ord(substr($c, 2, 1)) == 0x3af;
75print "ok 15\n";
bfa383d6 76
a72c7584 77# regex literals
78
79print "not " unless "\xDF" =~ /\x{3AF}/;
80print "ok 16\n";
81
82print "not " unless "\x{3AF}" =~ /\xDF/;
83print "ok 17\n";
84
85print "not " unless "\xDF" =~ /\xDF/;
86print "ok 18\n";
87
88print "not " unless "\x{3AF}" =~ /\x{3AF}/;
89print "ok 19\n";
90