From 2ff48fe49444158964d4c31105d49821f30e6157 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Fri, 5 Mar 2021 11:05:47 +0100 Subject: [PATCH] Add text.hexdump --- text.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/text.lua b/text.lua index 559c191..34b078e 100644 --- a/text.lua +++ b/text.lua @@ -62,6 +62,13 @@ function inputstream(text) return setmetatable({text = text, cursor = 0}, inputstream_metatable) end +function hexdump(text) + local dump = {} + for index = 1, text:len() do + dump[index] = ("%02X"):format(text:byte(index)) + end + return table.concat(dump) +end function split(text, delimiter, limit, is_regex) limit = limit or math.huge