Redis arabic language decoding

716 views Asked by At

I use Redis with PHP, with phpRedis connector. When i save a word in arabic language I can't retrieve this word, it's return encoding values.

In redis the problem is solved if I connect with: >redis-cli --raw

Example here:

amic:/var/www/core-bitercash$ redis-cli 127.0.0.1:6379> set xx جيد OK 127.0.0.1:6379> get xx "\xd8\xac\xd9\x8a\xd8\xaf"

amic:/var/www/core-bitercash$ redis-cli --raw 127.0.0.1:6379> get xx جيد 127.0.0.1:6379>

Yes it's work, but for phpRedis is don't work. Is return: جيد

the value saved in redis.

I don't know how to connect with --raw option for phpRedis lib or haw to decode the text "جيØ" in php.

1

There are 1 answers

1
Niloct On BEST ANSWER

Add the key in Redis as you posted in your question, save this code as test.php on your webserver and open the page in your browser, do the chars show up correctly ?

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
</head>
<body>
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo $redis->get('xx');
?>
</body>
</html>

If that fails to work, include this code at the beginning of the page:

<?php ini_set('default_charset', 'utf-8'); ?>