hex_dump
Definition
-- @/lua/common/utils.lua:1456
--pairs = sortedPairs -- uncomment this line to make 'pairs' deterministic (see also: unsortedPairs)
function hex_dump(str)
local len, hex, asc = string.len(str), '', ''
for i = 1, len do
if i % 8 == 1 then
print(hex .. asc)
hex, asc = string.format("%04x: ", i - 1), ''
end
local ord = string.byte(str, i)
hex = hex .. string.format("%02x ", ord)
asc = asc .. ((ord >= 32 and ord <= 126) and string.char(ord) or ".")
end
print(hex .. string.rep(" ", 8 - len % 8 ) .. asc)
end
Callers
@/lua/ge/extensions/ui/console.lua
log("I", "exec", "GELua(Queue) hex_dump="..hex_dump(cmd))
log("I", "exec", "GELua(Queue) < "..dumps(cmd))