How to realize the method of viewing Chinese non-garbled code on redis command line
This article mainly shows you the "redis command line how to view Chinese non-garbled code method", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "redis command line how to view Chinese non-garbled code method" this article.
Redis command line to check the Chinese code
When using the command line operation, Redis will display the hexadecimal string "\ xe4\ xb8\ xad\ xe5\ x9b\ xbd" if the view contains Chinese characters.
127.0.0.1 get 6379 > set K1 'China' OK127.0.0.1:6379 > get K1 "\ xe4\ xb8\ xad\ xe5\ x9b\ xbd"
If you want to see Chinese characters that are not garbled, there are two solutions:
First, use echo
$echo-e `redis-cli get k1` China
Second, add-raw after redis-cli
$redis-cli-- raw127.0.0.1:6379 > get K1 China
The following is a detailed introduction to the relevant examples of Redis processing using hexadecimal strings, as follows:
In the process of using Redis, the Chinese content is stored in hexadecimal form, so when using the redis-cli client connection, the Chinese part of the content will be displayed in hexadecimal form, so it is a bit inconvenient to query the data content in redis. In fact, the hexadecimal content found can be used to transform the queried hexadecimal content with the "- e" parameter in echo under the Unix system, as follows:
127.0.0.1 xe4 6379 > get test1 "test\ xe6\ x8c\ x81\ xe4\ xb9\ x85\ xe5\ x8c\ x96" 127.0.0.1 xe6 6379 > 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, you can use the "--raw" parameter of the redis-cli client itself to output the original content when connecting to the redis:
[root@localhost ~] # redis-cli-- raw 127.0.0.1 raw 6379 > persistence these are all the contents of this article entitled "how to check the Chinese code on the command line of redis". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!