summaryrefslogtreecommitdiff
path: root/cpan/Encode/Encode.pm
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2010-09-18 21:29:05 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2010-09-18 21:29:05 +0100
commit45a6a02cb9a19e39a4a35e0428611cf7b34fd39e (patch)
treefc90eb0ca05adb06a5bbbd5e5496fc0ce11cd545 /cpan/Encode/Encode.pm
parente86c8c9d6da6c53aa2b53fdfb9803aaf5264a6ad (diff)
downloadperl-45a6a02cb9a19e39a4a35e0428611cf7b34fd39e.tar.gz
Upgrade Encode from 2.39 to 2.40
Diffstat (limited to 'cpan/Encode/Encode.pm')
-rw-r--r--cpan/Encode/Encode.pm36
1 files changed, 25 insertions, 11 deletions
diff --git a/cpan/Encode/Encode.pm b/cpan/Encode/Encode.pm
index f1dff7820c..4e8cd3c7e5 100644
--- a/cpan/Encode/Encode.pm
+++ b/cpan/Encode/Encode.pm
@@ -1,10 +1,10 @@
#
-# $Id: Encode.pm,v 2.39 2009/11/26 09:23:48 dankogai Exp $
+# $Id: Encode.pm,v 2.40 2010/09/18 18:39:51 dankogai Exp dankogai $
#
package Encode;
use strict;
use warnings;
-our $VERSION = sprintf "%d.%02d", q$Revision: 2.39 $ =~ /(\d+)/g;
+our $VERSION = sprintf "%d.%02d", q$Revision: 2.40 $ =~ /(\d+)/g;
sub DEBUG () { 0 }
use XSLoader ();
XSLoader::load( __PACKAGE__, $VERSION );
@@ -203,18 +203,32 @@ sub encode_utf8($) {
return $str;
}
+my $utf8enc;
+
sub decode_utf8($;$) {
- my ( $str, $check ) = @_;
- return $str if is_utf8($str);
- if ($check) {
- return decode( "utf8", $str, $check );
- }
- else {
- return decode( "utf8", $str );
- return $str;
- }
+ my ( $octets, $check ) = @_;
+ return $octets if is_utf8($octets);
+ return undef unless defined $octets;
+ $octets .= '' if ref $octets;
+ $check ||= 0;
+ $utf8enc ||= find_encoding('utf8');
+ my $string = $utf8enc->decode( $octets, $check );
+ $_[0] = $octets if $check and !ref $check and !( $check & LEAVE_SRC() );
+ return $string;
}
+# sub decode_utf8($;$) {
+# my ( $str, $check ) = @_;
+# return $str if is_utf8($str);
+# if ($check) {
+# return decode( "utf8", $str, $check );
+# }
+# else {
+# return decode( "utf8", $str );
+# return $str;
+# }
+# }
+
predefine_encodings(1);
#