1#!perl -w 2 3BEGIN { 4 if ($] < 5.006) { 5 print "1..0 # Skipped: your perl don't know unicode\n"; 6 exit; 7 } 8} 9 10print "1..3\n"; 11 12use strict; 13use Digest::MD5 qw(md5_hex); 14 15my $str; 16$str = "foo\xFF\x{100}"; 17 18eval { 19 print md5_hex($str); 20 print "not ok 1\n"; # should not run 21}; 22print "not " unless $@ && $@ =~ /^(Big byte|Wide character)/; 23print "ok 1\n"; 24 25my $exp = ord "A" == 193 ? # EBCDIC 26 "c307ec81deba65e9a222ca81cd8f6ccd" : 27 "503debffe559537231ed24f25651ec20"; # Latin 1 28 29chop($str); # only bytes left 30print "not " unless md5_hex($str) eq $exp; 31print "ok 2\n"; 32 33# reference 34print "not " unless md5_hex("foo\xFF") eq $exp; 35print "ok 3\n"; 36