1 # $Id: enc_eucjp.t,v 1.4 2003/04/24 17:43:16 dankogai Exp $
2 # This is the twin of enc_utf8.t .
5 require Config; import Config;
6 if ($Config{'extensions'} !~ /\bEncode\b/) {
7 print "1..0 # Skip: Encode was not built\n";
10 unless (find PerlIO::Layer 'perlio') {
11 print "1..0 # Skip: PerlIO was not built\n";
14 if (ord("A") == 193) {
15 print "1..0 # encoding pragma does not support EBCDIC platforms\n";
18 if ($] <= 5.008 and !$Config{perl_patchlevel}){
19 print "1..0 # Skip: Perl 5.8.1 or later required\n";
24 use encoding 'euc-jp';
26 my @c = (127, 128, 255, 256);
28 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.
68 print $a =~ qr{^utf8 "\\x80" does not map to Unicode} ?
69 "ok $t - illegal utf8 input\n" : "not ok $t - illegal utf8 input: a = " . unpack("H*", $a) . "\n";