# Revision history for Perl extension Encode.
#
-# $Id: Changes,v 1.56 2002/04/22 09:48:07 dankogai Exp dankogai $
+# $Id: Changes,v 1.57 2002/04/22 20:27:30 dankogai Exp dankogai $
#
-$Revision: 1.56 $ $Date: 2002/04/22 09:48:07 $
+$Revision: 1.57 $ $Date: 2002/04/22 20:27:30 $
+! t/JP.t t/KR.t t/perlio.t
+ unless (find PerlIO::Layer 'perlio') ... line is back again.
+ t/JP.t and t/KR.t were supposed to work but maybe '>:utf8' lines
+ need PerlIO. Sigh....
+! Encode.xs Unicode/Unicode.pm lib/Encode/JP/JIS7.pm t/perlio.t
+ ->perlio_ok now does eval{ require PerlIO::encoding } there so
+ it correctly returns 1 when PerlIO::encoding is yet loaded.
+! Encode.xs
+ perl-current patch #16072 reflected
+
+1.56 2002/04/22 09:48:07
! Encode.pm encoding.pm t/perlio.t t/jperl.t
New PerlIO::encoding 0.04 compliance met
Typo fixes and improvements by jhi
Message-Id: <200204010201.FAA03564@alpha.hut.fi>, et al.
-1.11 $Date: 2002/04/22 09:48:07 $
+1.11 $Date: 2002/04/22 20:27:30 $
+ t/encoding.t
+ t/jperl.t
! MANIFEST
package Encode;
use strict;
-our $VERSION = do { my @r = (q$Revision: 1.56 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.57 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
our $DEBUG = 0;
use XSLoader ();
XSLoader::load 'Encode';
}
sub perlio_ok{
- exists $INC{"PerlIO/encoding.pm"} or return 0;
my $obj = ref($_[0]) ? $_[0] : find_encoding($_[0]);
- $obj->can("perlio_ok") and return $obj->perlio_ok() unless $@;
+ $obj->can("perlio_ok") and return $obj->perlio_ok();
return 0; # safety net
}
/*
- $Id: Encode.xs,v 1.33 2002/04/22 03:43:05 dankogai Exp $
+ $Id: Encode.xs,v 1.34 2002/04/22 20:27:30 dankogai Exp dankogai $
*/
#define PERL_NO_GET_CONTEXT
return (y)0; /* fool picky compilers */ \
}
/**/
+
UNIMPLEMENTED(_encoded_utf8_to_bytes, I32)
UNIMPLEMENTED(_encoded_bytes_to_utf8, I32)
CODE:
{
encode_t *enc = INT2PTR(encode_t *, SvIV(SvRV(obj)));
+ require_pv(PERLIO_FILENAME);
if (hv_exists(get_hv("INC", 0),
PERLIO_FILENAME, strlen(PERLIO_FILENAME)))
{
use strict;
use warnings;
-our $VERSION = do { my @r = (q$Revision: 1.34 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.35 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
use XSLoader;
XSLoader::load(__PACKAGE__,$VERSION);
sub needs_lines { 0 };
sub perlio_ok {
- exists $INC{"PerlIO/encoding.pm"} or return 0;
- return 1;
+ eval{ require PerlIO::encoding };
+ if ($@){
+ return 0;
+ }else{
+ return 1;
+ }
}
use strict;
use vars qw($VERSION);
-$VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+$VERSION = do { my @r = (q$Revision: 1.3 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
use Encode ();
use Encode::CN;
sub needs_lines { 1 }
sub perlio_ok {
- # exists $INC{"PerlIO/encoding.pm"} or return 0;
- # PerlIO::encoding->VERSION >= 0.03 and return 1;
return 0; # for the time being
}
package Encode::Encoding;
# Base class for classes which implement encodings
use strict;
-our $VERSION = do { my @r = (q$Revision: 1.27 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.28 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
sub Define
{
method so that it returns 1 when PerlIO is enabled. Here is an
example;
- sub perlio_ok { exists $INC{"PerlIO/encoding.pm"} }
+ sub perlio_ok {
+ eval { require PerlIO::encoding };
+ if ($@){
+ return 0;
+ }else{
+ return 1;
+ }
+ }
+
By default, this method is defined as follows;
package Encode::JP::JIS7;
use strict;
-our $VERSION = do { my @r = (q$Revision: 1.5 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.6 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
use Encode qw(:fallbacks);
sub needs_lines { 1 }
sub perlio_ok {
- exists $INC{"PerlIO/encoding.pm"} or return 0;
- PerlIO::encoding->VERSION >= 0.03 and return 1;
- return 0;
+ eval{ require PerlIO::encoding };
+ if ($@){
+ return 0;
+ }else{
+ return (PerlIO::encoding->VERSION >= 0.03);
+ }
}
use Encode::CJKConstants qw(:all);
use strict;
-our $VERSION = do { my @r = (q$Revision: 1.3 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.4 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
my $canon = 'iso-2022-kr';
sub needs_lines { 1 }
sub perlio_ok {
- #exists $INC{"PerlIO/encoding.pm"} or return 0;
- #PerlIO::encoding->VERSION >= 0.03 and return 1;
return 0; # for the time being
}
print "1..0 # Skip: EBCDIC\n";
exit 0;
}
+ unless (PerlIO::Layer->find('perlio')){
+ print "1..0 # Skip: PerlIO required\n";
+ exit 0;
+ }
$| = 1;
}
use strict;
is(compare_text($utf, $ref), 0, "$utf eq $ref");
open $src, "<:utf8", $ref or die "$ref : $!";
+ binmode($src);
$uni = join('', <$src>);
close $src;
print "1..0 # Skip: Encode was not built\n";
exit 0;
}
- unless (find PerlIO::Layer 'perlio') {
- print "1..0 # Skip: PerlIO was not built\n";
- exit 0;
- }
if (ord("A") == 193) {
print "1..0 # Skip: EBCDIC\n";
exit 0;
}
+ unless (PerlIO::Layer->find('perlio')){
+ print "1..0 # Skip: PerlIO required\n";
+ exit 0;
+ }
$| = 1;
}
use strict;
-use Test::More tests => 15;
+use Test::More tests => 11;
#use Test::More qw(no_plan);
use Encode;
use File::Basename;
use File::Spec;
-use File::Compare;
+use File::Compare qw(compare_text);
require_ok "Encode::KR";
my ($src, $uni, $dst, $txt, $euc, $utf, $ref, $rnd);
is($enc->name,'euc-kr');
my $dir = dirname(__FILE__);
-my @subcodings = qw(ksc5601);
-
-for my $subcoding (@subcodings){
- $euc = File::Spec->catfile($dir,"$subcoding.euc");
+for my $charset (qw(ksc5601)){
+ $euc = File::Spec->catfile($dir,"$charset.euc");
$utf = File::Spec->catfile($dir,"$$.utf8");
- $ref = File::Spec->catfile($dir,"$subcoding.ref");
+ $ref = File::Spec->catfile($dir,"$charset.ref");
$rnd = File::Spec->catfile($dir,"$$.rnd");
- print "# Basic decode test\n";
- open($src,"<",$euc) || die "Cannot open $euc:$!";
+
+ open($src,"<",$euc) or die "Cannot open $euc:$!";
binmode($src);
- ok(defined($src) && fileno($src));
$txt = join('',<$src>);
- open($dst,">:utf8",$utf) || die "Cannot open $utf:$!";
- binmode($dst);
- ok(defined($dst) && fileno($dst));
- eval{ $uni = $enc->decode($txt,1) };
+ close($src);
+
+ eval{ $uni = $enc->decode($txt, 1) };
$@ and print $@;
- ok(defined($uni));
- is(length($txt),0);
+ ok(defined($uni), "decode $charset");
+ is(length($txt),0, "decode $charset completely");
+
+ open($dst,">:utf8",$utf) or die "Cannot open $utf:$!";
+ binmode($dst);
print $dst $uni;
- close($dst);
- close($src);
- ok(compare($utf,$ref) == 0);
-}
+ close($dst);
+ is(compare_text($utf, $ref), 0, "$utf eq $ref");
+
+ open $src, "<:utf8", $ref or die "$ref : $!";
+ binmode($src);
+ $uni = join('', <$src>);
+ close $src;
-print "# Basic encode test\n";
-open($src,"<:utf8",$ref) || die "Cannot open $ref:$!";
-binmode($src);
-ok(defined($src) && fileno($src));
-$uni = join('',<$src>);
-open($dst,">",$rnd) || die "Cannot open $rnd:$!";
-binmode($dst);
-ok(defined($dst) && fileno($dst));
-$txt = $enc->encode($uni,1);
-ok(defined($txt));
-is(length($uni),0);
-print $dst $txt;
-close($dst);
-close($src);
-ok(compare($euc,$rnd) == 0);
+ for my $canon (qw(euc-kr)){
+ my $test = \&is;
+ if ($charset eq 'jisx0201'){
+ $canon eq 'iso-2022-jp' and $test = \&isnt;
+ $canon eq 'iso-2022-jp-1' and $test = \&isnt;
+ }elsif($charset eq 'jisx0212'){
+ $canon eq 'shiftjis' and $test = \&isnt;
+ $canon eq 'iso-2022-jp' and $test = \&isnt;
+ }
+ my $rt = ($test eq \&is) ? 'RT' : 'non-RT';
+ $test->($uni, decode($canon, encode($canon, $uni)),
+ "$rt $charset $canon");
+
+ }
-is($enc->name,'euc-kr');
+ eval{ $txt = $enc->encode($uni,1) };
+ $@ and print $@;
+ ok(defined($txt), "encode $charset");
+ is(length($uni), 0, "encode $charset completely");
+
+ open($dst,">", $rnd) or die "Cannot open $utf:$!";
+ binmode($dst);
+ print $dst $txt;
+ close($dst);
+ is(compare_text($euc, $rnd), 0 => "$rnd eq $euc");
+}
END {
1 while unlink($utf,$rnd);
#
-# $Id: jperl.t,v 1.23 2002/04/22 09:48:07 dankogai Exp dankogai $
+# $Id: jperl.t,v 1.23 2002/04/22 09:48:07 dankogai Exp $
#
# This script is written in euc-jp
print "1..0 # Skip: EBCDIC\n";
exit 0;
}
+ unless (PerlIO::Layer->find('perlio')){
+ print "1..0 # Skip: PerlIO required\n";
+ exit 0;
+ }
$| = 1;
}
our $DEBUG = 0;
use Encode (":all");
-eval { require PerlIO::encoding };
-
{
no warnings;
@ARGV and $DEBUG = shift;