laixintao / iredis

Interactive Redis: A Terminal Client for Redis with AutoCompletion and Syntax Highlighting.
https://iredis.xbin.io
BSD 3-Clause "New" or "Revised" License
2.52k stars 102 forks source link

Support hexadecimal notation #337

Open huaouo opened 4 years ago

huaouo commented 4 years ago

Results from redis-cli:

root@f3119c650ec1:/usr/local/bin# ./redis-cli
127.0.0.1:6379> set 0 \x00
OK
127.0.0.1:6379> bitcount 0
(integer) 12
127.0.0.1:6379> set 0 '\x00'
OK
127.0.0.1:6379> bitcount 0
(integer) 12
127.0.0.1:6379> set 0 "\x00"
OK
127.0.0.1:6379> bitcount 0
(integer) 0

Results from iredis:

PS C:\Users\huaouo> iredis
iredis  1.6.2 (Python 3.7.7)
redis-server  6.0.3
Home:   https://iredis.io
Issues: https://iredis.io/issues
127.0.0.1:6379> set 0 \x00
OK
127.0.0.1:6379> bitcount 0
(integer) 12
127.0.0.1:6379> set 0 '\x00'
OK
127.0.0.1:6379> bitcount 0
(integer) 12
127.0.0.1:6379> set 0 "\x00"
OK
127.0.0.1:6379> bitcount 0
(integer) 12
laixintao commented 4 years ago

Thanks for reporting.

It seems that when using single quotes or no quote, \x00 will be sent as a string, but in double-quotes then hex value will be interpreted as number 0.

I tested it with this script:

$ redis-cli -p 7889
127.0.0.1:7889> set 0 "\x00"
OK
127.0.0.1:7889> set 0 '\x00'
OK
127.0.0.1:7889> set 0 \x00
OK
127.0.0.1:7889>

RESP content:

 => $3
 => set
 => $1
 => 0
 => $1
 =>
<=  +OK
 => *3
 => $3
 => set
 => $1
 => 0
 => $4
 => \x00
<=  +OK
 => *3
 => $3
 => set
 => $1
 => 0
 => $4
 => \x00
<=  +OK
laixintao commented 4 years ago

I am wondering how did you find out about this? I didn't see redis-doc mentioned this anywhere. :)