#
-# $Id: Encode.pm,v 1.64 2002/04/29 06:54:06 dankogai Exp $
+# $Id: Encode.pm,v 1.75 2002/06/01 18:07:42 dankogai Exp $
#
package Encode;
use strict;
-our $VERSION = do { my @r = (q$Revision: 1.64 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.75 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
our $DEBUG = 0;
use XSLoader ();
XSLoader::load(__PACKAGE__, $VERSION);
sub encode($$;$)
{
- my ($name,$string,$check) = @_;
+ my ($name, $string, $check) = @_;
$check ||=0;
my $enc = find_encoding($name);
unless(defined $enc){
the result is always off, even when it contains completely valid utf8
string. See L</"The UTF-8 flag"> below.
+encode($valid_encoding, undef) is harmless but warns you for
+C<Use of uninitialized value in subroutine entry>.
+encode($valid_encoding, '') is harmless and warnless.
+
=item $string = decode(ENCODING, $octets [, CHECK])
Decodes a sequence of octets assumed to be in I<ENCODING> into Perl's
ASCII data (or EBCDIC on EBCDIC machines). See L</"The UTF-8 flag">
below.
+decode($valid_encoding, undef) is harmless but warns you for
+C<Use of uninitialized value in subroutine entry>.
+decode($valid_encoding, '') is harmless and warnless.
+
=item [$length =] from_to($octets, FROM_ENC, TO_ENC [, CHECK])
Converts B<in-place> data between two encodings. The data in $octets
while(defined(read $fh, $buffer, 256)){
# buffer may end in a partial character so we append
$data .= $buffer;
- $utf8 .= decode($encoding, $data, ENCODE::FB_QUIET);
+ $utf8 .= decode($encoding, $data, Encode::FB_QUIET);
# $data now contains the unprocessed partial character
}
FB_DEFAULT FB_CROAK FB_QUIET FB_WARN FB_PERLQQ
DIE_ON_ERR 0x0001 X
- WARN_ON_ER 0x0002 X
+ WARN_ON_ERR 0x0002 X
RETURN_ON_ERR 0x0004 X X
LEAVE_SRC 0x0008
PERLQQ 0x0100 X
In the future, you will be able to use a code reference to a callback
function for the value of I<CHECK> but its API is still undecided.
+The fallback scheme does not work on EBCDIC platforms.
+
=head1 Defining Encodings
To define a new encoding, use: