Open Klaranth opened 2 years ago
interesting. Any examples of nodes that produce that?
@SwissalpS Please ask Huhhila in-game.
I really wish Github would stop removing texts inside < > .... :P
I really wish Github would stop removing texts inside < > .... :P
You need to escape them with backslashes: \<player\>
@SwissalpS Please ask Huhhila in-game.
please stop telling me that. The discusion is here. Huhhila reads these threads too. Besides, others may know too.
Huhhila @SwissalpS : added invalid-unicode testcase recently as O-155 in lga's museum (the random-colored digiterms:lcd_monitor).
abc to hex
local abc = ("abc"):gsub(".",
function(c)
return ("0x%x "):format(string.byte(c))
end
)
-- abc == "0x61 0x62 0x63 "
not too clean and leaves extra space but gives basic idea how to do it easily.
edit. better format string for < 0x10 == "0x%02x" (to always have leading zero): Also shows that lua strings can represent any character, not null terminated (and lua strings are just byte arrays so also no encoding)
local s = "abc"
for i=0,9 do
s = s .. string.char(i)
end
local hexdump = (s):gsub(".",
function(c)
return ("0x%02x "):format(string.byte(c))
end
)
print('"'..hexdump..'"')
--[[ prints (leading zero too, no grouping, single line, has final trailing space):
"0x61 0x62 0x63 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 "
--]]
So just add grouping / formatting / line breaks / whatever helpers.
If reordering bytes for different endianness is needed then probably best to do with number tables for buffering and to keep memory consumption sane for large strings.
Huhhila Make inspector:inspector do hex dump instead of " < invalid UTF-8 string > " when encountering junk; (preferably xxd-style hex dump).