Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
package Encoded_GDBM_File;
require 5.000;
use English qw/ $PERL_VERSION /;
use GDBM_File qw/ GDBM_WRCREAT GDBM_READER GDBM_WRITER /;
use strict;
use vars qw/ @EXPORT @ISA /;
@ISA = qw/ GDBM_File /;
@EXPORT = qw/ GDBM_WRCREAT GDBM_READER GDBM_WRITER /;
=head1 NAME
Encoded_GDBM_File - Wrapper class of GDBM_File
=head1 SYNOPSIS
use Encoded_GDBM_File;
use encoding "euc-jp";
tie( %hash, 'Encoded_GDBM_File', $dbfile, &GDBM_WRCREAT, 0640 ) or die;
$hash{"¥،¼"} = "أح";
while( my( $key, $value ) = each %hash ){
print "$key:$value\n";
}
=head1 DESCRIPTION
Because Perl-5.8 uses Unicode as an internal representation of
characters, it is necessary either to encode or to decode keys and
values when accessing databases.
This class is designed to resolve these troubles, and encode keys and
values transparently when fetching them from a database or storing
them into it.
=head1 ENCODING
When using this class, it is necessary to specify the coding system,
which is used in your database, with C pragma. If there is
no C pragma in the script, this class does no conversion.
=cut
sub _encode {
my( $string ) = @_;
if( $string and $PERL_VERSION > 5.008 and ${^ENCODING} ){
${^ENCODING}->encode( $string );
} else {
$string;
}
}
sub _decode {
my( $string ) = @_;
if( $string and $PERL_VERSION > 5.008 and ${^ENCODING} ){
${^ENCODING}->decode( $string );
} else {
$string;
}
}
sub FETCH {
my( $this, $key ) = @_;
&_decode( $this->SUPER::FETCH( &_encode( $key ) ) );
}
sub STORE {
my( $this, $key, $value ) = @_;
$this->SUPER::STORE( &_encode( $key ), &_encode( $value ) );
}
sub DELETE {
my( $this, $key ) = @_;
$this->SUPER::DELETE( &_encode( $key ) );
}
sub EXISTS {
my( $this, $key ) = @_;
$this->SUPER::EXISTS( &_encode( $key ) );
}
sub FIRSTKEY {
my( $this ) = @_;
&_decode( $this->SUPER::FIRSTKEY() );
}
sub NEXTKEY {
my( $this, $lastkey ) = @_;
&_decode( $this->SUPER::NEXTKEY( &_encode( $lastkey ) ) );
}
1;
=head1 SEE ALSO
=over 4
=item *
L
=item *
L
=back
=head1 AUTHOR
=over 4
=item
TSUCHIYA Masatoshi
=back
=head1 LICENSE
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, you can either send email to this
program's maintainer or write to: The Free Software Foundation,
Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
Last Update: $Date: 2004/01/29 08:37:08 $
=cut
__END__
# Local Variables:
# mode: perl
# coding: euc-japan
# End: