# Revision history for Perl extension Encode.
#
-# $Id: Changes,v 1.76 2002/08/25 15:09:51 dankogai Exp dankogai $
+# $Id: Changes,v 1.77 2002/10/06 03:27:02 dankogai Exp dankogai $
#
-$Revision: 1.76 $ $Date: 2002/08/25 15:09:51 $
+$Revision: 1.77 $ $Date: 2002/10/06 03:27:02 $
+! t/jperl.t
+ * Modified to accomodate up and comming patch by Inaba-san that
+ will fix tr/// needing eval qq{}
+ Message-Id: <9F78A19C-D6C3-11D6-BAC6-0003939A104C@dan.co.jp>
+! encoding.pm
+ * pod fixes/enhancements to reflect the changes above
+! lib/Encode/Alias.pm
+ "Encode::TW is correct, Encode::Alias not." - /Autrijus/
+ Message-Id: <20021001015648.GB18710@not.autrijus.org>
+
+1.76 2002/08/25 15:09:51
! t/big5-eten.utf
To reflect ucm change by Autrijus. t/big5-eten.enc was regenerated
but naturally identical to previous version -- dankogai
Typo fixes and improvements by jhi
Message-Id: <200204010201.FAA03564@alpha.hut.fi>, et al.
-1.11 $Date: 2002/08/25 15:09:51 $
+1.11 $Date: 2002/10/06 03:27:02 $
+ t/encoding.t
+ t/jperl.t
! MANIFEST
#
-# $Id: Encode.pm,v 1.76 2002/08/25 15:09:51 dankogai Exp dankogai $
+# $Id: Encode.pm,v 1.77 2002/10/06 03:26:54 dankogai Exp $
#
package Encode;
use strict;
-our $VERSION = do { my @r = (q$Revision: 1.76 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.77 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
our $DEBUG = 0;
use XSLoader ();
XSLoader::load(__PACKAGE__, $VERSION);
*encode = \&encode_classic;
}else{
require Carp;
- Carp::croak(__PACKAGE__, "::set_transcoder(modern|classic|xs)");
+ Carp::croak __PACKAGE__, "::set_transcoder(modern|classic|xs)";
}
}
my $msg = shift;
my $pair = join(", ", map {sprintf "\\x%x", $_} @_);
require Carp;
- Carp::croak($obj->name, ":", $msg, "<$pair>.", caller);
+ Carp::croak $obj->name, ":", $msg, "<$pair>.", caller;
}
1;
package encoding;
-our $VERSION = do { my @r = (q$Revision: 1.36 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.37 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
use Encode;
use strict;
s/\bCamel\b/$Rakuda/;
The B<encoding> pragma also modifies the filehandle disciplines of
-STDIN, STDOUT, and STDERR to the specified encoding. Therefore,
+STDIN and STDOUT to the specified encoding. Therefore,
use encoding "euc-jp";
my $message = "Camel is the symbol of perl.\n";
So feel free to put your strings in your encoding in quotes and
regexes.
+=head2 tr/// with ranges remain unaffected
+
+The B<encoding> pragma works by decoding string literals in
+C<q//,qq//,qr//,qw///, qx//> and so forth. As of perl 5.8.0, this
+does not apply to C<tr///>. Therefore,
+
+ use encoding 'euc-jp';
+ #....
+ $kana =~ tr/\xA4\xA1-\xA4\xF3/\xA5\xA1-\xA5\xF3/;
+ # -------- -------- -------- --------
+
+Does not work as
+
+ $kana =~ tr/\x{3041}-\x{3093}/\x{30a1}-\x{30f3}/;
+
+=over
+
+=item Legend of characters above
+
+ utf8 euc-jp charnames::viacode()
+ -----------------------------------------
+ \x{3041} \xA4\xA1 HIRAGANA LETTER SMALL A
+ \x{3093} \xA4\xF3 HIRAGANA LETTER N
+ \x{30a1} \xA5\xA1 KATAKANA LETTER SMALL A
+ \x{30f3} \xA5\xF3 KATAKANA LETTER N
+
+=back
+
+=head3 workaround to tr///;
+
+You can, however, achieve the same as simply as follows;
+
+ use encoding 'euc-jp';
+ # ....
+ eval qq{ \$kana =~ tr/\xA4\xA1-\xA4\xF3/\xA5\xA1-\xA5\xF3/ };
+
+Note the C<tr//> expression is surronded by C<qq{}>. The idea behind
+is the same as classic idiom that makes C<tr///> 'interpolate'.
+
+ tr/$from/$to/; # wrong!
+ eval qq{ tr/$from/$to/ }; # workaround.
+
+Nevertheless, in case of B<encoding> pragma even C<q//> is affected so
+C<tr///> not being decoded was obviously against the will of Perl5
+Porters. In future version of perl, this counter-intuitive behaviour
+of C<tr///> will be fixed so C<eval qq{}> trick will be unneccesary.
+
=head1 Non-ASCII Identifiers and Filter option
The magic of C<use encoding> is not applied to the names of
package Encode::Alias;
use strict;
use Encode;
-our $VERSION = do { my @r = (q$Revision: 1.33 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.34 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
our $DEBUG = 0;
use base qw(Exporter);
define_alias( qr/\bks_c_5601-1987$/i => '"cp949"' );
# for Encode::TW
define_alias( qr/\bbig-?5$/i => '"big5-eten"' );
- define_alias( qr/\bbig5-?et(?:en)$/i => '"big5-eten"' );
+ define_alias( qr/\bbig5-?et(?:en)?$/i => '"big5-eten"' );
define_alias( qr/\btca[-_]?big5$/i => '"big5-eten"' );
define_alias( qr/\bbig5-?hk(?:scs)?$/i => '"big5-hkscs"' );
define_alias( qr/\bhk(?:scs)?[-_]?big5$/i => '"big5-hkscs"' );
require Carp;
my $obj = shift;
my $class = ref($obj) ? ref($obj) : $obj;
- Carp::croak($class, "->encode() not defined!");
+ Carp::croak $class, "->encode() not defined!";
}
sub decode{
require Carp;
my $obj = shift;
my $class = ref($obj) ? ref($obj) : $obj;
- Carp::croak($class, "->encode() not defined!");
+ Carp::croak $class, "->encode() not defined!";
}
sub DESTROY {}
#
-# $Id: jperl.t,v 1.24 2002/04/26 03:02:04 dankogai Exp $
+# $Id: jperl.t,v 1.25 2002/10/06 03:27:02 dankogai Exp dankogai $
#
# This script is written in euc-jp
no utf8; # we have raw Japanese encodings here
use strict;
-use Test::More tests => 18;
+#use Test::More tests => 18;
+use Test::More tests => 15; # black magic tests commented out
my $Debug = shift;
no encoding; # ensure
}
# should've been isnt() but no scoping is suported -- yet
ok(! defined(${^ENCODING}), q{not scoped yet});
-{
- # now let's try some real black magic!
- local(${^ENCODING}) = Encode::find_encoding("euc-jp");
- my $str = "\xbe\xae\xbb\xf4\x20\xc3\xc6";
- is (length($str), 4, q{black magic:length});
- is ($str, $Enamae, q{black magic:eq});
-}
-ok(! defined(${^ENCODING}), q{out of black magic});
+
+#
+# The following tests are commented out to accomodate
+# Inaba-San's patch to make tr/// work w/o eval qq{}
+#{
+# # now let's try some real black magic!
+# local(${^ENCODING}) = Encode::find_encoding("euc-jp");
+# my $str = "\xbe\xae\xbb\xf4\x20\xc3\xc6";
+# is (length($str), 4, q{black magic:length});
+# is ($str, $Enamae, q{black magic:eq});
+#}
+#ok(! defined(${^ENCODING}), q{out of black magic});
use bytes;
is (length($Namae), 10);
#
-# $Id: big5-eten.ucm,v 1.3 2002/08/25 15:09:51 dankogai Exp dankogai $
+# $Id: big5-eten.ucm,v 1.3 2002/08/25 15:09:51 dankogai Exp $
#
# ./compile -n big5-eten -o Encode/big5-eten.ucm Encode/big5-eten.enc
<code_set_name> "big5-eten"