summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Encode.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-04-05 22:27:26 +0000
committerKarl Berry <karl@freefriends.org>2016-04-05 22:27:26 +0000
commitb56b320b5e2515160073fa1b469514002688fe11 (patch)
tree965a7100c5e45fca8ec803d22b8b6ce14fca4633 /Master/tlpkg/tlperl/lib/Encode.pm
parentd26c206452d2e285c3bbf949f34011e4a55fd8f9 (diff)
tlperl 5.22.1 from siep
git-svn-id: svn://tug.org/texlive/trunk@40252 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Encode.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/Encode.pm44
1 files changed, 35 insertions, 9 deletions
diff --git a/Master/tlpkg/tlperl/lib/Encode.pm b/Master/tlpkg/tlperl/lib/Encode.pm
index 5d477f6bdec..3bb10970de6 100644
--- a/Master/tlpkg/tlperl/lib/Encode.pm
+++ b/Master/tlpkg/tlperl/lib/Encode.pm
@@ -1,10 +1,10 @@
#
-# $Id: Encode.pm,v 2.60 2014/04/29 16:26:49 dankogai Exp dankogai $
+# $Id: Encode.pm,v 2.72 2015/03/14 02:43:24 dankogai Exp $
#
package Encode;
use strict;
use warnings;
-our $VERSION = sprintf "%d.%02d", q$Revision: 2.60_01 $ =~ /(\d+)/g;
+our $VERSION = sprintf "%d.%02d", q$Revision: 2.72 $ =~ /(\d+)/g;
use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG};
use XSLoader ();
XSLoader::load( __PACKAGE__, $VERSION );
@@ -156,7 +156,20 @@ sub encode($$;$) {
require Carp;
Carp::croak("Unknown encoding '$name'");
}
- my $octets = $enc->encode( $string, $check );
+ # For Unicode, warnings need to be caught and re-issued at this level
+ # so that callers can disable utf8 warnings lexically.
+ my $octets;
+ if ( ref($enc) eq 'Encode::Unicode' ) {
+ my $warn = '';
+ {
+ local $SIG{__WARN__} = sub { $warn = shift };
+ $octets = $enc->encode( $string, $check );
+ }
+ warnings::warnif('utf8', $warn) if length $warn;
+ }
+ else {
+ $octets = $enc->encode( $string, $check );
+ }
$_[1] = $string if $check and !ref $check and !( $check & LEAVE_SRC() );
return $octets;
}
@@ -172,7 +185,20 @@ sub decode($$;$) {
require Carp;
Carp::croak("Unknown encoding '$name'");
}
- my $string = $enc->decode( $octets, $check );
+ # For Unicode, warnings need to be caught and re-issued at this level
+ # so that callers can disable utf8 warnings lexically.
+ my $string;
+ if ( ref($enc) eq 'Encode::Unicode' ) {
+ my $warn = '';
+ {
+ local $SIG{__WARN__} = sub { $warn = shift };
+ $string = $enc->decode( $octets, $check );
+ }
+ warnings::warnif('utf8', $warn) if length $warn;
+ }
+ else {
+ $string = $enc->decode( $octets, $check );
+ }
$_[1] = $octets if $check and !ref $check and !( $check & LEAVE_SRC() );
return $string;
}
@@ -457,7 +483,7 @@ If the $string is C<undef>, then C<undef> is returned.
This function returns the string that results from decoding the scalar
value I<OCTETS>, assumed to be a sequence of octets in I<ENCODING>, into
-Perl's internal form. The returns the resulting string. As with encode(),
+Perl's internal form. As with encode(),
I<ENCODING> can be either a canonical name or an alias. For encoding names
and aliases, see L</"Defining Aliases">; for I<CHECK>, see L</"Handling
Malformed Data">.
@@ -547,7 +573,7 @@ Also note that:
from_to($octets, $from, $to, $check);
-is equivalent t:o
+is equivalent to:
$octets = encode($to, decode($from, $octets), $check);
@@ -674,7 +700,7 @@ In the first version above, you let the appropriate encoding layer
handle the conversion. In the second, you explicitly translate
from one encoding to the other.
-Unfortunately, it may be that encodings are C<PerlIO>-savvy. You can check
+Unfortunately, it may be that encodings are not C<PerlIO>-savvy. You can check
to see whether your encoding is supported by C<PerlIO> by invoking the
C<perlio_ok> method on it:
@@ -810,7 +836,7 @@ 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
+example if you wish to decode octets 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 {
@@ -1029,7 +1055,7 @@ who submitted code to the project.
=head1 COPYRIGHT
-Copyright 2002-2013 Dan Kogai I<< <dankogai@cpan.org> >>.
+Copyright 2002-2014 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.