X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2FEncode%2FEncode.pm;h=3b3fd9771ba376d309a389f47b3a29148d657780;hb=ca777f1ce1ff5cad164a769e07ab2e03b14695b6;hp=d1c5494587660aa4e8ef4f6d9180f3ec77af5e44;hpb=44a4342c9f1bf4dd16241a6721340a5828ede477;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/Encode/Encode.pm b/ext/Encode/Encode.pm index d1c5494..3b3fd97 100644 --- a/ext/Encode/Encode.pm +++ b/ext/Encode/Encode.pm @@ -2,11 +2,11 @@ package Encode; use strict; our $VERSION = do { my @r = (q$Revision: 1.50 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; our $DEBUG = 0; +use XSLoader (); +XSLoader::load 'Encode'; -require DynaLoader; require Exporter; - -our @ISA = qw(Exporter DynaLoader); +our @ISA = qw(Exporter); # Public, encouraged API is exported by default @@ -19,7 +19,7 @@ our @FB_FLAGS = qw(DIE_ON_ERR WARN_ON_ERR RETURN_ON_ERR LEAVE_SRC PERLQQ); our @FB_CONSTS = qw(FB_DEFAULT FB_QUIET FB_WARN FB_PERLQQ FB_CROAK); our @EXPORT_OK = - ( + ( qw( _utf8_off _utf8_on define_encoding from_to is_16bit is_8bit is_utf8 perlio_ok resolve_alias utf8_downgrade utf8_upgrade @@ -27,16 +27,13 @@ our @EXPORT_OK = @FB_FLAGS, @FB_CONSTS, ); -our %EXPORT_TAGS = +our %EXPORT_TAGS = ( all => [ @EXPORT, @EXPORT_OK ], fallbacks => [ @FB_CONSTS ], fallback_all => [ @FB_CONSTS, @FB_FLAGS ], ); - -bootstrap Encode (); - # Documentation moved after __END__ for speed - NI-S use Carp; @@ -57,7 +54,7 @@ sub encodings my @modules = (@_ and $_[0] eq ":all") ? values %ExtModule : @_; for my $mod (@modules){ $mod =~ s,::,/,g or $mod = "Encode/$mod"; - $mod .= '.pm'; + $mod .= '.pm'; $DEBUG and warn "about to require $mod;"; eval { require $mod; }; } @@ -193,7 +190,7 @@ predefine_encodings(); # This is to restore %Encoding if really needed; # sub predefine_encodings{ - if ($ON_EBCDIC) { + if ($ON_EBCDIC) { # was in Encode::UTF_EBCDIC package Encode::UTF_EBCDIC; *name = sub{ shift->{'Name'} }; @@ -202,7 +199,7 @@ sub predefine_encodings{ my ($obj,$str,$chk) = @_; my $res = ''; for (my $i = 0; $i < length($str); $i++) { - $res .= + $res .= chr(utf8::unicode_to_native(ord(substr($str,$i,1)))); } $_[1] = '' if $chk; @@ -212,15 +209,15 @@ sub predefine_encodings{ my ($obj,$str,$chk) = @_; my $res = ''; for (my $i = 0; $i < length($str); $i++) { - $res .= + $res .= chr(utf8::native_to_unicode(ord(substr($str,$i,1)))); } $_[1] = '' if $chk; return $res; }; - $Encode::Encoding{Unicode} = + $Encode::Encoding{Unicode} = bless {Name => "UTF_EBCDIC"} => "Encode::UTF_EBCDIC"; - } else { + } else { # was in Encode::UTF_EBCDIC package Encode::Internal; *name = sub{ shift->{'Name'} }; @@ -232,7 +229,7 @@ sub predefine_encodings{ return $str; }; *encode = \&decode; - $Encode::Encoding{Unicode} = + $Encode::Encoding{Unicode} = bless {Name => "Internal"} => "Encode::Internal"; } @@ -256,15 +253,14 @@ sub predefine_encodings{ $_[1] = '' if $chk; return $octets; }; - $Encode::Encoding{utf8} = + $Encode::Encoding{utf8} = bless {Name => "utf8"} => "Encode::utf8"; } } require Encode::Encoding; +@Encode::XS::ISA = qw(Encode::Encoding); -eval qq{ use PerlIO::encoding 0.02 }; -# warn $@ if $@; 1; @@ -281,14 +277,14 @@ Encode - character encodings =head2 Table of Contents -Encode consists of a collection of modules which details are too big +Encode consists of a collection of modules which details are too big to fit in one document. This POD itself explains the top-level APIs -and general topics at a glance. For other topics and more details, +and general topics at a glance. For other topics and more details, see the PODs below; Name Description -------------------------------------------------------- - Encode::Alias Alias defintions to encodings + Encode::Alias Alias definitions to encodings Encode::Encoding Encode Implementation Base Class Encode::Supported List of Supported Encodings Encode::CN Simplified Chinese Encodings @@ -359,7 +355,7 @@ alias. For encoding names and aliases, see L. For CHECK see L. For example to convert (internally UTF-8 encoded) Unicode string to -iso-8859-1 (also known as Latin1), +iso-8859-1 (also known as Latin1), $octets = encode("iso-8859-1", $unicode); @@ -439,7 +435,7 @@ When "::" is not in the name, "Encode::" is assumed. @ebcdic = Encode->encodings("EBCDIC"); -To find which encodings are supported by this package in details, +To find which encodings are supported by this package in details, see L. =head2 Defining Aliases @@ -462,7 +458,7 @@ i.e. Encode::resolve_alias("iso-8859-12") # false; nonexistent Encode::resolve_alias($name) eq $name # true if $name is canonical -This resolve_alias() does not need C and is +This resolve_alias() does not need C and is exported via C. See L on details. @@ -481,7 +477,7 @@ totally identical by functionality. # via from_to open my $in, $infile or die; open my $out, $outfile or die; - while(<>){ + while(<>){ from_to($_, "shiftjis", "euc", 1); } @@ -508,7 +504,7 @@ If I is 0, (en|de)code will put I in place of the malformed character. for UCM-based encodings, EsubcharE will be used. For Unicode, \xFFFD is used. If the data is supposed to be UTF-8, an optional lexical warning (category -utf8) is given. +utf8) is given. =item I = Encode::DIE_ON_ERROR (== 1) @@ -519,10 +515,10 @@ with eval{} unless you really want to let it die on error. =item I = Encode::FB_QUIET If I is set to Encode::FB_QUIET, (en|de)code will immediately -return proccessed part on error, with data passed via argument -overwritten with unproccessed part. This is handy when have to +return processed part on error, with data passed via argument +overwritten with unprocessed part. This is handy when have to repeatedly call because the source data is chopped in the middle for -some reasons, such as fixed-width buffer. Here is a sample code that +some reasons, such as fixed-width buffer. Here is a sample code that just does this. my $data = ''; @@ -547,7 +543,7 @@ When you decode, '\xI' will be placed where I is the hex representation of the octet that could not be decoded to utf8. And when you encode, '\x{I}' will be placed where I is the Unicode ID of the character that cannot be found in the character -repartoire of the encoding. +repertoire of the encoding. =item The bitmask @@ -616,12 +612,12 @@ not a string. L, L, -L, +L, L, -L, -L, -L, -L, +L, +L, +L, +L, the Perl Unicode Mailing List Eperl-unicode@perl.orgE =head1 MAINTAINER