diff options
author | Steve Hay <steve.m.hay@googlemail.com> | 2014-05-06 20:40:56 +0100 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2014-05-06 20:40:56 +0100 |
commit | dc396cc29397b262d3cc1473ade4229c84e82ca3 (patch) | |
tree | 86ffb09680df8f668a1d1f31df41c1b05e4f3c0a /cpan/Encode/Encode.pm | |
parent | f751400fc758ae12ae31a028a617eea43132a3ec (diff) | |
download | perl-dc396cc29397b262d3cc1473ade4229c84e82ca3.tar.gz |
Upgrade to Encode-2.60
This upgrade includes the blead customizations from 080a704606 and
9e9002efd1 (amongst other changes) so that Perl 5.20.0 can ship with an
official CPAN release of Encode.
Diffstat (limited to 'cpan/Encode/Encode.pm')
-rw-r--r-- | cpan/Encode/Encode.pm | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/cpan/Encode/Encode.pm b/cpan/Encode/Encode.pm index a5be18bc2e..9dc970b299 100644 --- a/cpan/Encode/Encode.pm +++ b/cpan/Encode/Encode.pm @@ -1,10 +1,10 @@ # -# $Id: Encode.pm,v 2.57 2014/01/03 04:51:39 dankogai Exp $ +# $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.57_01 $ =~ /(\d+)/g; +our $VERSION = sprintf "%d.%02d", q$Revision: 2.60 $ =~ /(\d+)/g; use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG}; use XSLoader (); XSLoader::load( __PACKAGE__, $VERSION ); @@ -801,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: |