Perl utf8

Brad Fitzpatrick brad at danga.com
Mon Nov 21 16:52:33 PST 2005


On Mon, 21 Nov 2005, Dave Evans wrote:

> On Mon, Nov 21, 2005 at 04:50:54PM -0500, Paul Dlug wrote:
> > I'm having an issue getting Cache::Memcached (perl) to handle utf8 strings.
> > I've tried calling encode_utf8() and decode_utf8() when setting/getting
> > strings in the cache but this doesn't seem to help.
>
> That sounds like the right way to fix the problem.  What goes wrong with the
> approach, exactly?

Actually that sounds like exactly the wrong way to fix the problem.

Instead, the Perl module should note the utf8 flag on the Perl scalar,
save it into memcached (which just stores bytes, and a bitmask of
client-defined flags), and then restore the utf8 flag on the way out.

For now, a workaround is to put all utf8 data into memcached as an
arrayref:

   $memc->set("foo", [ $utf8_string ]);

which will force Storable.pm to be used, which handles the utf8 flagging
and unflagging.



>
> --
> Dave Evans
>
> PGP key: http://rudolf.org.uk/pgpkey
>
>


More information about the memcached mailing list