Conversion of sequence of bytes to ASCII string in lua
<p>I am trying to write custom dissector for Wireshark, which will change byte/hex output to ASCII string.</p>

<p>I was able to write the body of this dissector and it works. My only problem is conversion of this data to ASCII string.</p>

<p>Wireshark declares this data to be sequence of bytes.
To Lua the data type is <code>userdata</code> (tested using <code>type(data)</code>).
If I simply convert it to string using <code>tostring(data)</code> my dissector returns <code>24:50:48</code>, which is the exact hex representation of bytes in an array.</p>

<p>Is there any way to directly convert this byte sequence to ascii, or can you help me convert this colon separated string to ascii string? I am totally new to Lua. I've tried something like <code>split(tostring(data),":")</code> but this returns <code>Lua Error: attempt to call global 'split' (a nil value)</code></p>

<hr>

<p>Using Jakuje's answer I was able to create something like this:</p>

<pre><code>function isempty(s)
  return s == nil or s == ''
end
data = "24:50:48:49:4A"
s = ""
for i in string.gmatch(data, "[^:]*") do
    if not isempty( i ) then
        print(string.char(tonumber(i,16)))
        s = s .. string.char(tonumber(i,16))
    end
end
print( s )
</code></pre>

<p>I am not sure if this is effective, but at least it works ;)</p>