use strict;
no warnings 'redefine';
use Encode;
-our $VERSION = do { my @r = (q$Revision: 1.35 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
-our $DEBUG = 0;
+our $VERSION = do { my @r = (q$Revision: 2.0 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+sub DEBUG () { 0 }
use base qw(Exporter);
my $new;
if (ref($alias) eq 'Regexp' && $find =~ $alias)
{
- $DEBUG and warn "eval $val";
+ DEBUG and warn "eval $val";
$new = eval $val;
- $DEBUG and $@ and warn "$val, $@";
+ DEBUG and $@ and warn "$val, $@";
}
elsif (ref($alias) eq 'CODE')
{
- $DEBUG and warn "$alias", "->", "($find)";
+ DEBUG and warn "$alias", "->", "($find)";
$new = $alias->($find);
}
elsif (lc($find) eq lc($alias))
if (defined($new))
{
next if $new eq $find; # avoid (direct) recursion on bugs
- $DEBUG and warn "$alias, $new";
+ DEBUG and warn "$alias, $new";
my $enc = (ref($new)) ? $new : Encode::find_encoding($new);
if ($enc)
{
}
}
}
- if ($DEBUG){
+ if (DEBUG){
my $name;
if (my $e = $Alias{$find}){
$name = $e->name;
for my $k (@a){
if (ref($alias) eq 'Regexp' && $k =~ $alias)
{
- $DEBUG and warn "delete \$Alias\{$k\}";
+ DEBUG and warn "delete \$Alias\{$k\}";
delete $Alias{$k};
}
elsif (ref($alias) eq 'CODE')
{
- $DEBUG and warn "delete \$Alias\{$k\}";
+ DEBUG and warn "delete \$Alias\{$k\}";
delete $Alias{$alias->($name)};
}
}
}else{
- $DEBUG and warn "delete \$Alias\{$alias\}";
+ DEBUG and warn "delete \$Alias\{$alias\}";
delete $Alias{$alias};
}
}
# define_alias( qr/\bmacRomanian$/i => '"macRumanian"');
# Standardize on the dashed versions.
- # define_alias( qr/\butf8$/i => 'utf-8' );
- define_alias( qr/\bkoi8r$/i => 'koi8-r' );
- define_alias( qr/\bkoi8u$/i => 'koi8-u' );
+ # define_alias( qr/\butf8$/i => '"utf-8"' );
+ define_alias( qr/\bkoi8[\s-_]*([ru])$/i => '"koi8-$1"' );
unless ($Encode::ON_EBCDIC){
# for Encode::CN
# CP936 doesn't have vendor-addon for GBK, so they're identical.
define_alias( qr/^gbk$/i => '"cp936"');
# This fixes gb2312 vs. euc-cn confusion, practically
- define_alias( qr/\bGB[-_ ]?2312(?:\D.*$|$)/i => '"euc-cn"' );
+ define_alias( qr/\bGB[-_ ]?2312(?!-?raw)/i => '"euc-cn"' );
# for Encode::JP
define_alias( qr/\bjis$/i => '"7bit-jis"' );
define_alias( qr/\beuc.*jp$/i => '"euc-jp"' );