Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support hexadecimal notation #337

Open
huaouo opened this issue May 23, 2020 · 2 comments
Open

Support hexadecimal notation #337

huaouo opened this issue May 23, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@huaouo
Copy link

huaouo commented May 23, 2020

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
Copy link
Owner

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 laixintao added the bug Something isn't working label May 23, 2020
@laixintao
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants