why string "hello" is "\x45hello" not "\x85hello"?

#2 · open · 3 comments

View on GitHub ↗

xiebruce

The length of "hello" is 5, it's less then 63, so it matches this format ``` 10|xxxxxx <string-data> ``` The first 2bit is `10`, and the rest 6bit representing the length of the `<string-data>`, in this case, is 5(the length of "hello"),5 convert to binary code is `101`, we use `000` the make it reach 6bit, so it should be `000101`, `10` concat `000101` is `10000101`, convert it to hex is `0x85` not `0x45`, so am I wrong? or you make a mistake? <img width="638" alt="image" src="https://user-images.githubusercontent.com/13575500/179285192-5d5466b0-f7f7-4ec8-9067-47becbaff40f.png">

Comments

Hccake

Found the same issue, I thought the value should be `0x85`, the documentation was wrong

xiebruce

Sadly, no one merge [this PR](https://github.com/antirez/listpack/pull/3/commits/4377c2173ebe9cdc2cf3220e31eaf96c0f3baebf) <img width="1391" alt="image" src="https://github.com/antirez/listpack/assets/13575500/5df2356b-60bf-449e-8983-61fc265352b6">

zhouyecs

🤔 the examples in https://github.com/antirez/listpack/blob/master/listpack.md#element-total-length-field should also be ``` "\x85hello" -- The string "hello" ``` ``` "\x85hello\x06" -- A complete entry representing "hello" ```