pawitp / protobuf-decoder

JavaScript-based web UI to decode ad-hoc Protobuf data
https://protobuf-decoder.netlify.app/
MIT License
392 stars 91 forks source link

Support interpreting varint values as signed (zig zag encoded) #37

Closed jeff303 closed 3 years ago

jeff303 commented 3 years ago

Add new util function to translate unsigned value to signed

Add the signed value to the return from decodeVarint by calling fn

Add call to the new function from ProtobufVarintPart display code

jeff303 commented 3 years ago

I wasn't sure the right way to approach this from the display perspective, so it has to re-interpret the String there. It seemed that parts was always just for a single value, so I had trouble returning the numeric type directly from there (instead of the String, as it works now).

Fixes #36

jeff303 commented 3 years ago

The current version has some issue, as you can see on the Netlify preview site with the demo value in the readme

image

Just realized that decodeVarint is supposed to be a generic decoding function, probably we should leave it as it and create another one (with another name? darn naming) in protobufPartDecoder.js.

Sorry it's been a while since I've last worked on this project. If you'd like, I'll fix it myself this weekend.

OK, I think I understood all of this. Made a separate function within protobufPartDecoder.js that might return multiple values (if they differ), and kept decodVarint as it was.

pawitp commented 3 years ago

image

Works great now! Thank you for your contribution 👍

obrassard commented 3 years ago

Nice !! Good job 👍