}
# If octal representation of unicode char is \0xyzt, then the utf8 is \3xy\2zt
-$encoded_be = "\320\261";
-$encoded_alpha = "\316\261";
-$encoded_bet = "\327\221";
-$encoded_deseng = "\360\220\221\215";
+if (ord('A') == 65) { # as on ASCII or UTF-8 machines
+ $encoded_be = "\320\261";
+ $encoded_alpha = "\316\261";
+ $encoded_bet = "\327\221";
+ $encoded_deseng = "\360\220\221\215";
+}
+else { # EBCDIC where UTF-EBCDIC may be used (this may be 1047 specific since
+ # UTF-EBCDIC is codepage specific)
+ $encoded_be = "\270\102\130";
+ $encoded_alpha = "\264\130";
+ $encoded_bet = "\270\125\130";
+ $encoded_deseng = "\336\102\103\124";
+}
sub to_bytes {
pack"a*", shift;
# UTF8 ~ behaviour
#
+my $Is_EBCDIC = (ord('A') == 193) ? 1 : 0;
+
my @not36;
for (0x100...0xFFF) {
$a = ~(chr $_);
- push @not36, sprintf("%#03X", $_)
- if $a ne chr(~$_) or length($a) != 1 or ~$a ne chr($_);
+ if ($Is_EBCDIC) {
+ push @not36, sprintf("%#03X", $_)
+ if $a ne chr(~$_) or length($a) != 1;
+ }
+ else {
+ push @not36, sprintf("%#03X", $_)
+ if $a ne chr(~$_) or length($a) != 1 or ~$a ne chr($_);
+ }
}
if (@not36) {
print "# test 36 failed\n";
for my $i (0xEEE...0xF00) {
for my $j (0x0..0x120) {
$a = ~(chr ($i) . chr $j);
- push @not37, sprintf("%#03X %#03X", $i, $j)
- if $a ne chr(~$i).chr(~$j) or
- length($a) != 2 or
- ~$a ne chr($i).chr($j);
+ if ($Is_EBCDIC) {
+ push @not37, sprintf("%#03X %#03X", $i, $j)
+ if $a ne chr(~$i).chr(~$j) or
+ length($a) != 2;
+ }
+ else {
+ push @not37, sprintf("%#03X %#03X", $i, $j)
+ if $a ne chr(~$i).chr(~$j) or
+ length($a) != 2 or
+ ~$a ne chr($i).chr($j);
+ }
}
}
if (@not37) {
}
print "ok 37\n";
-print "not " unless ~chr(~0) eq "\0";
+print "not " unless ~chr(~0) eq "\0" or $Is_EBCDIC;
print "ok 38\n";
my @not39;
print "1..30\n";
+my $Is_EBCDIC = (ord('A') == 193) ? 1 : 0;
+
print vec($foo,0,1) == 0 ? "ok 1\n" : "not ok 1\n";
print length($foo) == 0 ? "ok 2\n" : "not ok 2\n";
vec($foo,0,1) = 1;
eval { vec($foo, 1, 8) = 13 };
print "not " if $@;
print "ok 26\n";
-print "not " if $foo ne "\xc4\x0d\xc3\xbf\xc3\xbe";
-print "ok 27\n";
+if ($Is_EBCDIC) {
+ print "not " if $foo ne "\x8c\x0d\xff\x8a\x69";
+ print "ok 27\n";
+}
+else {
+ print "not " if $foo ne "\xc4\x0d\xc3\xbf\xc3\xbe";
+ print "ok 27\n";
+}
$foo = "\x{100}" . "\xff\xfe";
$x = substr $foo, 1;
vec($x, 2, 4) = 7;
}
print "ok $test\n"; ++$test;
- print "not " unless
- sprintf("%vd", 1.22.333.4444) eq '1.22.197.141.225.133.156';
+ if (ord("\t") == 9) { # ASCII
+ print "not " unless
+ sprintf("%vd", 1.22.333.4444) eq '1.22.197.141.225.133.156';
+ }
+ else {
+ print "not " unless
+ sprintf("%vd", 1.22.333.4444) eq '1.22.142.84.187.81.112';
+ }
print "ok $test\n"; ++$test;
if (ord("\t") == 9) { # ASCII
}
print "ok $test\n"; ++$test;
- print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.C5.8D.E1.85.9C';
+ if (ord("\t") == 9) { # ASCII
+ print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.C5.8D.E1.85.9C';
+ }
+ else {
+ print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.8E.54.BB.51.70';
+ }
print "ok $test\n"; ++$test;
if (ord("\t") == 9) { # ASCII
}
print "ok $test\n"; ++$test;
- print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
- eq '1##10110##11000101##10001101##11100001##10000101##10011100';
+ if (ord("\t") == 9) { # ASCII
+ print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
+ eq '1##10110##11000101##10001101##11100001##10000101##10011100';
+ }
+ else {
+ print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
+ eq '1##10110##10001110##1010100##10111011##1010001##1110000';
+ }
print "ok $test\n"; ++$test;
}