私は本当に奇妙なUTF-8の問題に遭遇しましたNet::Cassandra::Easy
(これはに基づいていますNet::Cassandra
):Cassandraに書き込まれたUTF-8文字列は取得時に文字化けします。
次のコードは問題を示しています。
use strict;
use utf8;
use warnings;
use Net::Cassandra::Easy;
binmode(STDOUT, ":utf8");
my $key = "some_key";
my $column = "some_column";
my $set_value = "\x{2603}"; # U+2603 is ☃ (SNOWMAN)
my $cassandra = Net::Cassandra::Easy->new(keyspace => "Keyspace1", server => "localhost");
$cassandra->connect();
$cassandra->mutate([$key], family => "Standard1", insertions => { $column => $set_value });
my $result = $cassandra->get([$key], family => "Standard1", standard => 1);
my $get_value = $result->{$key}->{"Standard1"}->{$column};
if ($set_value eq $get_value) {
# this is the path I want.
print "OK: $set_value == $get_value\n";
} else {
# this is the path I get.
print "ERR: $set_value != $get_value\n";
}
上記のコードを実行すると、$set_value eq $get_value
と評価されfalse
ます。私は何を間違っていますか?