6 unless (defined &perlio::import) {
7 print "1..0 # Skip: not perlio\n";
15 open(F,"+>:utf8",'a');
16 print F chr(0x100).'£';
17 print '#'.tell(F)."\n";
18 print "not " unless tell(F) == 4;
21 print '#'.tell(F)."\n";
22 print "not " unless tell(F) >= 5;
25 print "not " unless getc(F) eq chr(0x100);
27 print "not " unless getc(F) eq "£";
29 print "not " unless getc(F) eq "\n";
33 print "not " unless getc(F) eq chr(0xc4);
35 print "not " unless getc(F) eq chr(0x80);
37 print "not " unless getc(F) eq chr(0xc2);
39 print "not " unless getc(F) eq chr(0xa3);
41 print "not " unless getc(F) eq "\n";
45 print "not " unless scalar(<F>) eq "\x{100}£\n";
49 $count = read(F,$buf,2,1);
50 print "not " unless $count == 2;
52 print "not " unless $buf eq "\x{200}\x{100}£";
57 $a = chr(300); # This *is* UTF-encoded
58 $b = chr(130); # This is not.
60 open F, ">:utf8", 'a' or die $!;
64 open F, "<:utf8", 'a' or die $!;
67 print "not " unless $x eq chr(300);
70 open F, "a" or die $!; # Not UTF
73 print "not " unless $x eq chr(196).chr(172);
77 open F, ">:utf8", 'a' or die $!;
78 binmode(F); # we write a "\n" and then tell() - avoid CRLF issues.
82 { use bytes; $y = length($a);}
83 print "not " unless $x == $y;
87 { # Check byte length of $b
88 use bytes; my $y = length($b);
89 print "not " unless $y == 1;
93 print F $b,"\n"; # Don't upgrades $b
95 { # Check byte length of $b
96 use bytes; my $y = length($b);
97 print "not ($y) " unless $y == 1;
102 { use bytes; $y += 3;}
103 print "not ($x,$y) " unless $x == $y;
109 open F, "a" or die $!; # Not UTF
112 printf "not (%vd) ", $x unless $x eq v196.172.194.130;
115 open F, "<:utf8", "a" or die $!;
119 printf "not (%vd) ", $x unless $x eq chr(300).chr(130);
122 # Now let's make it suffer.
123 open F, ">", "a" or die $!;
124 eval { print F $a; };
125 print "not " unless $@ and $@ =~ /Wide character in print/i;
129 # Hm. Time to get more evil.
130 open F, ">:utf8", "a" or die $!;
132 binmode(F, ":bytes");
133 print F chr(130)."\n";
136 open F, "<", "a" or die $!;
138 print "not " unless $x eq v196.172.130;
142 open F, ">:utf8", "a" or die $!;
145 open F, ">>", "a" or die $!;
146 print F chr(130)."\n";
149 open F, "<", "a" or die $!;
151 print "not " unless $x eq v196.172.130;
154 # Now we have a deformed file.
155 open F, "<:utf8", "a" or die $!;
157 { local $SIG{__WARN__} = sub { print "ok 25\n"; };
158 eval { sprintf "%vd\n", $x; }