redis command line view Chinese non scrambled code method (hexadecimal string processing)

  • 2020-05-30 21:16:20
  • OfStack

redis command line view Chinese not messy code

When using the command line, Redis will display a hexadecimal string "\xe4\xb8\xad\xe5\x9b\xbd" if the contents contain Chinese.> set k1 ' China '
OK> get k1

If you want to see the Chinese characters, there are two solutions:

1. Use echo

$ echo -e `redis-cli get k1`

2. Add the hang raw to redis-cli

$ redis-cli --raw> get k1

Here is a detailed example of Redis's use of base 106 string manipulation, as follows:

Redis in the process of using a Chinese content are stored in 106 in the form of the system, when using redis - cli client connections so if it is a part of the contents have Chinese would be in the form of 106 into the system, so the data in a query redis content is a little too convenient, actually under the Unix system can look up to the 106 "- in hexadecimal content with echo e" parameter is used to convert the query to 106 base content, are as follows:> get test1 
"test\xe6\x8c\x81\xe4\xb9\x85\xe5\x8c\x96"> quit 
[root@localhost ~]# echo -e "test\xe6\x8c\x81\xe4\xb9\x85\xe5\x8c\x96" 
test persistence 

In addition, when using the redis-cli client, the "--raw" parameter of the redis-cli client itself can be used to output the original content when connecting to redis:

[root@localhost ~]# redis-cli --raw> get test1 
test persistence 


Related articles: