Author: hmbrand
Date: Thu Apr 22 11:15:07 2010
New Revision: 13913
Modified:
dbi/trunk/Changes
dbi/trunk/lib/DBD/File.pm
Log:
Added f_encoding support to DBD::File
Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes (original)
+++ dbi/trunk/Changes Thu Apr 22 11:15:07 2010
@@ -19,6 +19,7 @@
warning to not be issued if ReadOnly set for that dbh.
Added f_lock support to DBD::File (H.Merijn Brand)
+ Added f_encoding support to DBD::File (H.Merijn Brand)
Added ChildCallbacks => { ... } to Callbacks as a way to
specify Callbacks for child handles.
With tests added by David E. Wheeler.
Modified: dbi/trunk/lib/DBD/File.pm
==============================================================================
--- dbi/trunk/lib/DBD/File.pm (original)
+++ dbi/trunk/lib/DBD/File.pm Thu Apr 22 11:15:07 2010
@@ -163,6 +163,7 @@
f_schema => 1, # schema name
f_tables => 1, # base directory
f_lock => 1, # Table locking mode
+ f_encoding => 1, # Encoding of the file
};
$this->{sql_valid_attrs} = {
sql_handler => 1, # Nano or S:S
@@ -724,7 +725,14 @@
$safe_drop or croak "Cannot open $file: $!";
}
}
- $fh and binmode $fh;
+ if ($fh) {
+ if (my $enc = $data->{Database}{f_encoding}) {
+ binmode $fh, ":encoding($enc)";
+ }
+ else {
+ binmode $fh;
+ }
+ }
if ($locking and $fh) {
my $lm = defined $data->{Database}{f_lock}
&& $data->{Database}{f_lock} =~ m/^[012]$/
@@ -961,6 +969,11 @@
=back
+=item f_encoding
+
+With this attribute, you can set the encoding in which the file is opened.
+This is implemented using C<binmode $fh, ":encoding(<f_encoding>)">.
+
=head2 Driver private methods
=over 4