read/sysread/recv should now be utf8 aware.
[p5sagit/p5-mst-13.2.git] / t / io / utf8.t
CommitLineData
7d59b7e4 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require Config; import Config;
7 unless ($Config{'useperlio'}) {
8 print "1..0 # Skip: not perlio\n";
9 exit 0;
10 }
11}
12
13$| = 1;
eb5c063a 14print "1..13\n";
7d59b7e4 15
16open(F,"+>:utf8",'a');
17print F chr(0x100).'£';
18print '#'.tell(F)."\n";
19print "not " unless tell(F) == 4;
20print "ok 1\n";
21print F "\n";
22print '#'.tell(F)."\n";
23print "not " unless tell(F) >= 5;
24print "ok 2\n";
25seek(F,0,0);
26print "not " unless getc(F) eq chr(0x100);
27print "ok 3\n";
28print "not " unless getc(F) eq "£";
29print "ok 4\n";
30print "not " unless getc(F) eq "\n";
31print "ok 5\n";
32seek(F,0,0);
33binmode(F,":bytes");
34print "not " unless getc(F) eq chr(0xc4);
35print "ok 6\n";
36print "not " unless getc(F) eq chr(0x80);
37print "ok 7\n";
38print "not " unless getc(F) eq chr(0xc2);
39print "ok 8\n";
40print "not " unless getc(F) eq chr(0xa3);
41print "ok 9\n";
42print "not " unless getc(F) eq "\n";
43print "ok 10\n";
44seek(F,0,0);
45binmode(F,":utf8");
46print "not " unless scalar(<F>) eq "\x{100}£\n";
47print "ok 11\n";
eb5c063a 48seek(F,0,0);
49$buf = chr(0x200);
50$count = read(F,$buf,2,1);
51print "not " unless $count == 2;
52print "ok 12\n";
53print "not " unless $buf eq "\x{200}\x{100}£";
54print "ok 13\n";
7d59b7e4 55close(F);
56
57# unlink('a');
58