From c1c00721fa3e9052dce9d7c54bcc804f562a920a Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 17 Mar 2010 18:22:09 +0000 Subject: [PATCH] added use bytes to support utf-8 encoded strings We are not round-tripping utf-8 encoding strings correctly in this version. We will get string back wothout perl utf-8 flag git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/Redis@69 447b33ff-793d-4489-8442-9bea7d161be5 --- lib/Redis.pm | 2 ++ t/01-Redis.t | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Redis.pm b/lib/Redis.pm index 3cc595e..6a6aab3 100644 --- a/lib/Redis.pm +++ b/lib/Redis.pm @@ -77,6 +77,8 @@ our $AUTOLOAD; sub AUTOLOAD { my $self = shift; + use bytes; + my $sock = $self->{sock} || die "no server connected"; my $command = $AUTOLOAD; diff --git a/t/01-Redis.t b/t/01-Redis.t index a54d88c..756135a 100755 --- a/t/01-Redis.t +++ b/t/01-Redis.t @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 108; +use Test::More tests => 110; use Data::Dumper; use lib 'lib'; @@ -30,6 +30,10 @@ ok( $o->set( foo => 'baz' ), 'set foo => baz' ); cmp_ok( $o->get( 'foo' ), 'eq', 'baz', 'get foo = baz' ); +my $euro = "\x{20ac}"; +ok( $o->set( utf8 => $euro ), 'set utf8' ); +cmp_ok( $o->get( 'utf8' ), 'eq', $euro, 'get utf8' ); + ok( $o->set( 'test-undef' => 42 ), 'set test-undef' ); ok( $o->set( 'test-undef' => undef ), 'set undef' ); ok( ! defined $o->get( 'test-undef' ), 'get undef' ); -- 2.20.1