# Revision history for Perl extension Encode.
#
-# $Id: Changes,v 2.20 2007/04/22 14:56:12 dankogai Exp dankogai $
+# $Id: Changes,v 2.22 2007/05/29 07:35:27 dankogai Exp dankogai $
#
-$Revision: 2.20 $ $Date: 2007/04/22 14:56:12 $
+$Revision: 2.22 $ $Date: 2007/05/29 07:35:27 $
+! Encode.pm
+ from_to() does not honor the check while decoding. That's a feature.
+ To make sure it is a feature it is mentioned in the POD.
+ http://rt.cpan.org/NoAuth/Bug.html?id=#27277
+! Makefile.pl
+ Encode used to suppress man page generation. Now it does.
+ http://rt.cpan.org/NoAuth/Bug.html?id=#27200
+! Encode.pm Encode.xs t/fallback.t
+ Addressed: (de|en)code("ascii", "\x{3000}", sub{ $_[0] }) segfaults
+ Reported by MIYAGAWA
+
+2.21 2007/05/12 06:42:19
++ lib/Encode/MIME/Name.pm t/mime-name.t
+! Encode.pm Encode.xs lib/Encode/Encoding.pm
+ new method: mime_name()
+ inspired by: MIYAGAWA
+! t/encoding.t
+ Subject: Re: Compress::Zlib, pack "C" and utf-8 [PATCH]
+ From: Marc Lehmann <schmorp@schmorp.de>
+ Date: Thu, 12 Apr 2007 08:41:53 +0200
+ Message-ID: <20070412064153.GA22475@schmorp.de>
+ http://public.activestate.com/cgi-bin/perlbrowse/p/31194
+! Unicode/Unicode.pm
+ POD fix.
+ Message-Id: <20070417220547.GA11999@zetta.zet>
+
+2.20 2007/04/22 14:56:12
! Encode.pm
Pod fixes. Now find_encoding() is explained more in details.
+ lib/Encode/GSM0338.pm
#
-# $Id: Encode.pm,v 2.21 2007/05/12 06:42:19 dankogai Exp dankogai $
+# $Id: Encode.pm,v 2.22 2007/05/29 07:35:27 dankogai Exp dankogai $
#
package Encode;
use strict;
use warnings;
-our $VERSION = sprintf "%d.%02d", q$Revision: 2.21 $ =~ /(\d+)/g;
+our $VERSION = sprintf "%d.%02d", q$Revision: 2.22 $ =~ /(\d+)/g;
sub DEBUG () { 0 }
use XSLoader ();
XSLoader::load( __PACKAGE__, $VERSION );
Carp::croak("Unknown encoding '$name'");
}
my $octets = $enc->encode( $string, $check );
- $_[1] = $string if $check and !( $check & LEAVE_SRC() );
+ $_[1] = $string if $check and !ref $check and !( $check & LEAVE_SRC() );
return $octets;
}
*str2bytes = \&encode;
Carp::croak("Unknown encoding '$name'");
}
my $string = $enc->decode( $octets, $check );
- $_[1] = $octets if $check and !( $check & LEAVE_SRC() );
+ $_[1] = $octets if $check and !ref $check and !( $check & LEAVE_SRC() );
return $string;
}
*bytes2str = \&decode;
See L</"The UTF8 flag"> below.
+Also note that
+
+ from_to($octets, $from, $to, $check);
+
+is equivalent to
+
+ $octets = encode($to, decode($from, $octets), $check);
+
+Yes, it does not respect the $check during decoding. It is
+deliberately done that way. If you need minute control, C<decode>
+then C<encode> as follows;
+
+ $octets = encode($to, decode($from, $octets, $check_from), $check_to);
+
=item $octets = encode_utf8($string);
Equivalent to C<$octets = encode("utf8", $string);> The characters
/*
- $Id: Encode.xs,v 2.12 2007/05/12 06:42:19 dankogai Exp dankogai $
+ $Id: Encode.xs,v 2.13 2007/05/29 07:35:27 dankogai Exp dankogai $
*/
#define PERL_NO_GET_CONTEXT
{
dSP;
int argc;
- SV* retval;
+ SV *temp, *retval;
ENTER;
SAVETMPS;
PUSHMARK(sp);
if (argc != 1){
croak("fallback sub must return scalar!");
}
- retval = newSVsv(POPs);
+ temp = newSVsv(POPs);
PUTBACK;
FREETMPS;
LEAVE;
+ retval = newSVpv("",0);
+ sv_catsv(retval, temp);
return retval;
}
use strict;
#use Test::More qw(no_plan);
-use Test::More tests => 44;
+use Test::More tests => 48;
use Encode q(:all);
my $uo = '';
$dst = $ascii->decode($src, sub{ sprintf "[%02X]", shift });
is($dst, $uc, "coderef decode");
is($src, $ao, "coderef residue decode");
+
+$src = "\x{3000}";
+$dst = $ascii->encode($src, sub{ $_[0] });
+is $dst, 0x3000."", qq{$ascii->encode(\$src, sub{ \$_[0] } )};
+$dst = encode("ascii", "\x{3000}", sub{ $_[0] });
+is $dst, 0x3000."", qq{encode("ascii", "\\x{3000}", sub{ \$_[0] })};
+
+$src = pack "C*", 0xFF;
+$dst = $ascii->decode($src, sub{ $_[0] });
+is $dst, 0xFF."", qq{$ascii->encode(\$src, sub{ \$_[0] } )};
+$dst = decode("ascii", (pack "C*", 0xFF), sub{ $_[0] });
+is $dst, 0xFF."", qq{decode("ascii", (pack "C*", 0xFF), sub{ \$_[0] })};
#
-# $Id: mime-name.t,v 1.1 2007/05/12 06:42:19 dankogai Exp dankogai $
+# $Id: mime-name.t,v 1.1 2007/05/12 06:42:19 dankogai Exp $
# This script is written in utf8
#
BEGIN {