diff options
author | Karl Berry <karl@freefriends.org> | 2015-04-26 22:16:26 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-04-26 22:16:26 +0000 |
commit | 342e672574c4e67d510e46ab6acd0e21a7d0cf54 (patch) | |
tree | 79e04202d08c0404bbd780bd26c1e34710e539b6 /Master/tlpkg/tlperl/lib/Encode.pm | |
parent | be2706af7c57a0ef0f4d4e9f684ca4ef74922a82 (diff) |
(tl)perl 5.20.2 for windows, from siep
git-svn-id: svn://tug.org/texlive/trunk@37064 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Encode.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/Encode.pm | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/Master/tlpkg/tlperl/lib/Encode.pm b/Master/tlpkg/tlperl/lib/Encode.pm index fe81119ef7b..5d477f6bdec 100644 --- a/Master/tlpkg/tlperl/lib/Encode.pm +++ b/Master/tlpkg/tlperl/lib/Encode.pm @@ -1,16 +1,15 @@ # -# $Id: Encode.pm,v 2.49 2013/03/05 03:13:47 dankogai Exp dankogai $ +# $Id: Encode.pm,v 2.60 2014/04/29 16:26:49 dankogai Exp dankogai $ # package Encode; use strict; use warnings; -our $VERSION = sprintf "%d.%02d", q$Revision: 2.49 $ =~ /(\d+)/g; +our $VERSION = sprintf "%d.%02d", q$Revision: 2.60_01 $ =~ /(\d+)/g; use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG}; use XSLoader (); XSLoader::load( __PACKAGE__, $VERSION ); -require Exporter; -use base qw/Exporter/; +use Exporter 5.57 'import'; # Public, encouraged API is exported by default @@ -53,7 +52,7 @@ our %ExtModule; require Encode::Config; # See # https://bugzilla.redhat.com/show_bug.cgi?id=435505#c2 -# to find why sig handers inside eval{} are disabled. +# to find why sig handlers inside eval{} are disabled. eval { local $SIG{__DIE__}; local $SIG{__WARN__}; @@ -209,9 +208,8 @@ my $utf8enc; sub decode_utf8($;$) { my ( $octets, $check ) = @_; - return $octets if is_utf8($octets); return undef unless defined $octets; - $octets .= '' if ref $octets; + $octets .= ''; $check ||= 0; $utf8enc ||= find_encoding('utf8'); my $string = $utf8enc->decode( $octets, $check ); @@ -471,8 +469,7 @@ internal format: B<CAVEAT>: When you run C<$string = decode("utf8", $octets)>, then $string I<might not be equal to> $octets. Though both contain the same data, the -UTF8 flag for $string is on unless $octets consists entirely of ASCII data -on ASCII machines or EBCDIC on EBCDIC machines. See L</"The UTF8 flag"> +UTF8 flag for $string is on. See L</"The UTF8 flag"> below. If the $string is C<undef>, then C<undef> is returned. @@ -804,13 +801,24 @@ If you're not interested in this, then bitwise-OR it with the bitmask. =head2 coderef for CHECK As of C<Encode> 2.12, C<CHECK> can also be a code reference which takes the -ordinal value of the unmapped character as an argument and returns a string -that represents the fallback character. For instance: +ordinal value of the unmapped character as an argument and returns +octets that represent the fallback character. For instance: $ascii = encode("ascii", $utf8, sub{ sprintf "<U+%04X>", shift }); Acts like C<FB_PERLQQ> but U+I<XXXX> is used instead of C<\x{I<XXXX>}>. +Even the fallback for C<decode> must return octets, which are +then decoded with the character encoding that C<decode> accepts. So for +example if you wish to decode octests as UTF-8, and use ISO-8859-15 as +a fallback for bytes that are not valid UTF-8, you could write + + $str = decode 'UTF-8', $octets, sub { + my $tmp = chr shift; + from_to $tmp, 'ISO-8859-15', 'UTF-8'; + return $tmp; + }; + =head1 Defining Encodings To define a new encoding, use: @@ -1021,7 +1029,7 @@ who submitted code to the project. =head1 COPYRIGHT -Copyright 2002-2012 Dan Kogai I<< <dankogai@cpan.org> >>. +Copyright 2002-2013 Dan Kogai I<< <dankogai@cpan.org> >>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |