1 # $Id: enc_eucjp.t,v 1.2 2003/02/06 01:52:11 dankogai Exp dankogai $
2 # This is the twin of enc_utf8.t, the only difference is that
3 # this has "use encoding 'euc-jp'".
6 require Config; import Config;
7 if ($Config{'extensions'} !~ /\bEncode\b/) {
8 print "1..0 # Skip: Encode was not built\n";
11 unless (find PerlIO::Layer 'perlio') {
12 print "1..0 # Skip: PerlIO was not built\n";
15 if (ord("A") == 193) {
16 print "1..0 # encoding pragma does not support EBCDIC platforms\n";
19 if ($] <= 5.008 and !$Config{perl_patchlevel}){
20 print "1..0 # Skip: Perl 5.8.1 or later required\n";
25 use encoding 'euc-jp';
27 my @c = (127, 128, 255, 256);
29 print "1.." . (scalar @c + 1) . "\n";
35 open(F, ">f$i") or die "$0: failed to open 'f$i' for writing: $!";
38 print F pack("C" => $c[$i]);
45 open(F, "<f$i") or die "$0: failed to open 'f$i' for reading: $!";
49 print $o == $c[$i] ? "ok $t - utf8 I/O $c[$i]\n" : "not ok $t - utf8 I/O $c[$i]: $o != $c[$i]\n";
56 open(F, ">$f") or die "$0: failed to open '$f' for writing: $!";
57 binmode(F, ":raw"); # Output raw bytes.
58 print F chr(128); # Output illegal UTF-8.
60 open(F, $f) or die "$0: failed to open '$f' for reading: $!";
61 binmode(F, ":encoding(utf-8)");
64 local $SIG{__WARN__} = sub { $a = shift };
65 eval { <F> }; # This should get caught.
67 print $a =~ qr{^utf8 "\\x80" does not map to Unicode} ?
68 "ok $t - illegal utf8 input\n" : "not ok $t - illegal utf8 input: a = " . unpack("H*", $a) . "\n";