Accents stored in Redis not being readable

2019-01-18 04:24发布

Working with Redis 2.10 using redis-cli on Linux, I am faced with a problem regarding accents...

If I execute the command

set "string" "à"

=> I get "\xc3\xa0"

It seems each converted accent begin with "\xc3"

How do I get my original string back?

标签: redis
4条回答
Luminary・发光体
2楼-- · 2019-01-18 04:49

Try using

redis-cli --raw

It solved problem for me.

查看更多
欢心
3楼-- · 2019-01-18 05:02

"\xc3\xa0" is just Unicode "à" in UTF-8 encoding. Just decode the string and you're done...

查看更多
劫难
4楼-- · 2019-01-18 05:04

"you string".encode("utf-8") when you need get the string "you string".decode("utf-8")

查看更多
我命由我不由天
5楼-- · 2019-01-18 05:06

You need to spec the version of Redis and more importantly the client you are using.

If you are using a telnet client, the problem may be your client. Redis supports arbitrary bytes for values and UTF-8 is not a problem at all (if your client is properly converting the entered glyphs to the associated byte sequence.)

查看更多
登录 后发表回答