From: Dan Kogai Date: Sun, 6 Oct 2002 12:52:52 +0000 (+0900) Subject: [Encode] 1.77 Released X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4b291ae6c6eed18b8842058ee57489c11dec5862;p=p5sagit%2Fp5-mst-13.2.git [Encode] 1.77 Released Message-Id: <16D4C6C9-D8DF-11D6-A5EA-0003939A104C@dan.co.jp> p4raw-id: //depot/perl@18002 --- diff --git a/ext/Encode/Changes b/ext/Encode/Changes index 7eb50a4..18995ec 100644 --- a/ext/Encode/Changes +++ b/ext/Encode/Changes @@ -1,9 +1,20 @@ # 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 @@ -706,7 +717,7 @@ $Revision: 1.76 $ $Date: 2002/08/25 15:09:51 $ 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 diff --git a/ext/Encode/Encode.pm b/ext/Encode/Encode.pm index ded46b8..2500e14 100644 --- a/ext/Encode/Encode.pm +++ b/ext/Encode/Encode.pm @@ -1,9 +1,9 @@ # -# $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); diff --git a/ext/Encode/Unicode/Unicode.pm b/ext/Encode/Unicode/Unicode.pm index b09e126..fa508eb 100644 --- a/ext/Encode/Unicode/Unicode.pm +++ b/ext/Encode/Unicode/Unicode.pm @@ -60,7 +60,7 @@ sub set_transcoder{ *encode = \&encode_classic; }else{ require Carp; - Carp::croak(__PACKAGE__, "::set_transcoder(modern|classic|xs)"); + Carp::croak __PACKAGE__, "::set_transcoder(modern|classic|xs)"; } } @@ -258,7 +258,7 @@ sub poisoned2death{ 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; diff --git a/ext/Encode/encoding.pm b/ext/Encode/encoding.pm index 182d7c6..778b44b 100644 --- a/ext/Encode/encoding.pm +++ b/ext/Encode/encoding.pm @@ -1,5 +1,5 @@ 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; @@ -144,7 +144,7 @@ the code in UTF-8: s/\bCamel\b/$Rakuda/; The B 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"; @@ -237,6 +237,53 @@ resort to \x{....} just to spell your name in a native encoding. So feel free to put your strings in your encoding in quotes and regexes. +=head2 tr/// with ranges remain unaffected + +The B pragma works by decoding string literals in +C and so forth. As of perl 5.8.0, this +does not apply to C. 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 expression is surronded by C. The idea behind +is the same as classic idiom that makes C 'interpolate'. + + tr/$from/$to/; # wrong! + eval qq{ tr/$from/$to/ }; # workaround. + +Nevertheless, in case of B pragma even C is affected so +C not being decoded was obviously against the will of Perl5 +Porters. In future version of perl, this counter-intuitive behaviour +of C will be fixed so C trick will be unneccesary. + =head1 Non-ASCII Identifiers and Filter option The magic of C is not applied to the names of diff --git a/ext/Encode/lib/Encode/Alias.pm b/ext/Encode/lib/Encode/Alias.pm index 4572fb6..0622602 100644 --- a/ext/Encode/lib/Encode/Alias.pm +++ b/ext/Encode/lib/Encode/Alias.pm @@ -1,7 +1,7 @@ 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); @@ -219,7 +219,7 @@ sub init_aliases 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"' ); diff --git a/ext/Encode/lib/Encode/Encoding.pm b/ext/Encode/lib/Encode/Encoding.pm index 1d24e9c..1876cb7 100644 --- a/ext/Encode/lib/Encode/Encoding.pm +++ b/ext/Encode/lib/Encode/Encoding.pm @@ -36,14 +36,14 @@ sub encode { 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 {} diff --git a/ext/Encode/t/jperl.t b/ext/Encode/t/jperl.t index 82f7a84..e281624 100644 --- a/ext/Encode/t/jperl.t +++ b/ext/Encode/t/jperl.t @@ -1,5 +1,5 @@ # -# $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 @@ -23,7 +23,8 @@ BEGIN { 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 @@ -60,14 +61,18 @@ is(length($Namae), 4, q{utf8:length}); } # 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); diff --git a/ext/Encode/ucm/big5-eten.ucm b/ext/Encode/ucm/big5-eten.ucm index 1fe3a99..e3e4d58 100644 --- a/ext/Encode/ucm/big5-eten.ucm +++ b/ext/Encode/ucm/big5-eten.ucm @@ -1,5 +1,5 @@ # -# $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 "big5-eten"