Re: Database character sets
[prev]
[thread]
[next]
[Date index for 2005/02/22]
* Tom Insam shaped the electrons to say...
>I'd like to use Class::DBI and a database to store character sequences,
>as opposed to bytes, specifically I'd like things in the database to be
>encoded as utf-8 byte sequences everywhere. Although mysql4.1, which is
>my current development target, claims to support character sets on
>tables, it doesn't look like DBD::mysql knows how to deal with this.
>Anyway, it may be that we're moving DB servers, and I don't want to
>have to require that the new server knows about them.
>
>Is this a solved problem yet? I'm hoping that it _must_ be, but I can't
>find anything in the archives of this list or the wiki about it.
Perrin is right, in that it's more of a DBI issue, however, I've had to deal
with this as well. Assuming all of your data is flagged / encoded as UTF-8 on
the way into the database:
# overload Class::DBI's get, because DBI doesn't support auto-flagging of utf8
# data retrieved from the db, we need to do it ourselves.
sub get {
my $self = shift;
my $attr = shift;
my $data = $self->SUPER::get($attr, @_);
if ($] > 5.007) {
Encode::_utf8_on($data);
}
return $data;
}
-D
--
<noah> I used to be indecisive, but now I'm not sure.
|
|
Re: Database character sets
Dan Sully 18:04 on 22 Feb 2005
|