unicodeutf-8redis

How to save non-Ascii characters in redis HMSET?


I'd like to save Arabic characters like سلام in a redis hash, like this:

HMSET arabicHash "سلام" 5
OK

But the result is not as intended:

127.0.0.1:6379> HGETALL arabicHash
1) "\xd8\xb3\xd9\x84\xd8\xa7\xd9\x85"
2) "5"

I'm wondering if there is a way to save سلام directly inot redis set? And if not, how can I convert back "\xd8\xb3\xd9\x84\xd8\xa7\xd9\x85" to human-readable charachters after being retrived?

Update: I've tested on my Ubuntu Bash terminal, but the result is not formatted correctly here. The screenshot:

enter image description here


Solution

    1. You need to put quotes to enclose the key and value being stored in the hash.

    enter image description here

    Tested on try.redis.io ( it shows the redis output in utf-8 decode form )

    1. The text may showup as utf-8 encoded in redis response, but on decoding, it would show correctly in arabic characters