diff options
Diffstat (limited to 'src/syslua/lx')
-rw-r--r-- | src/syslua/lx/lxinit.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/syslua/lx/lxinit.lua b/src/syslua/lx/lxinit.lua index 1c8d116..055ffc9 100644 --- a/src/syslua/lx/lxinit.lua +++ b/src/syslua/lx/lxinit.lua @@ -38,3 +38,27 @@ function string.split(str, sep) str:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end + +function hexdump(str) + for i = 1, #str, 16 do + local b = {string.byte(str, i, math.min(i+15, #str))} + local s = "" + for j = 1, 16 do + if b[j] then + s = s .. string.format("%02x ", b[j]) + else + s = s .. ' ' + end + end + s = s .. '| ' + for j = 1, #b do + ss = string.char(b[j]) + if b[j] >= 32 and b[j] < 128 then + s = s .. string.char(b[j]) + else + s = s .. '.' + end + end + print(s) + end +end |