r/lua • u/EpicAura99 • Jul 22 '25
Help Working on a Wireshark parser, why does TreeItem:add_le() not reverse strings too?
My first instinct would be to post to r/wireshark, but last time I had a similar question I was directed here. Apologies if that’s incorrect.
Trying to fetch a little endian string, but it’s reversed because apparently the little endian add function only works on numbers? This feels really wrong, I can’t imagine why it works like this. Let me know if a more elegant way to display this is known.
4
Upvotes
5
u/PhilipRoman Jul 22 '25 edited Jul 22 '25
Not too familiar with this API, but generally string data does not care about endianness, since it is stored byte by byte, in increasing address order.
If this wasn't the case, imagine the crazy arithmetic your compiler would have to do every time you iterate characters in a string...
You can definitely write your own function which reverses the string, but I doubt that's what you really need. Either way this needs more context - is the string length constant? 4? 8?
1
u/PeriodicSeizures Jul 22 '25
Use add instead for strings and bytes
1
u/netsx Jul 22 '25
Endianness primarily applies to multi-byte integers (and floats i believe, but i dont often program with floats). Regular byte strings have no idea of endianness, its technically just an long collection of individual bytes.