print "1..0 # Skip: Encode was not built\n";
exit 0;
}
+ if (ord("A") == 193) {
+ print "1..0 # Skip: EBCDIC\n";
+ exit 0;
+ }
$| = 1;
}
use Encode qw(decode encode find_encoding _utf8_off);
#use Test::More qw(no_plan);
-use Test::More tests => 17;
+use Test::More tests => 29;
use_ok("Encode::Guess");
{
no warnings;
my $jisx0212 = File::Spec->catfile(dirname(__FILE__), 'jisx0212.utf');
open my $fh, $jisx0208 or die "$jisx0208: $!";
+binmode($fh);
$utf8off = join('' => <$fh>);
close $fh;
$utf8on = decode('utf8', $utf8off);
is (decode('Guess', encode('euc-jp', $utf8on)), $utf8on, "decode('Guess')");
eval{ encode('Guess', $utf8on) };
-like($@, qr/lazy/io, "no encode()");
+like($@, qr/not defined/io, "no encode()");
my %CJKT =
(
for my $name (keys %CJKT){
open my $fh, $CJKT{$name} or die "$CJKT{$name}: $!";
+ binmode($fh);
$utf8off = join('' => <$fh>);
close $fh;
is(guess_encoding($test)->name, $name, "CJKT:$name");
}
+my $ambiguous = "\x{5c0f}\x{98fc}\x{5f3e}";
+my $english = "The quick brown fox jumps over the black lazy dog.";
+for my $utf (qw/UTF-16 UTF-32/){
+ for my $bl (qw/BE LE/){
+ my $test = encode("$utf$bl" => $english);
+ is(guess_encoding($test)->name, "$utf$bl", "$utf$bl");
+ }
+}
+for my $bl (qw/BE LE/){
+ my $test = encode("UTF-16$bl" => $ambiguous);
+ my $result = guess_encoding($test);
+ ok(! ref($result), "UTF-16$bl:$result");
+}
+
+
+
+Encode::Guess->set_suspects();
+for my $jp (@jp){
+ # intentionally set $1 a priori -- see Changes
+ my $test = "English";
+ '$1' =~ m/^(.*)/o;
+ is(guess_encoding($test, ($jp))->name, 'ascii',
+ "ascii vs $jp (\$1 messed)");
+ $test = encode($jp, $test . "\n\x{65e5}\x{672c}\x{8a9e}");
+ is(guess_encoding($test, ($jp))->name,
+ $jp, "$jp vs ascii (\$1 messed)");
+}
+
__END__;