lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> There's probably a good reason why this is not already part of lua, can
> anybody shed some light on this ?

To avoid bloat and also because the perfect place for such a feature is
in a text-encoding library (which would also handle base64, ascii85, etc.)
Also, it is trivial to write it in Lua:

local XT={}
for c=0,255 do
	XT[string.format("%02X",c)]=string.char(c)
	XT[string.format("%02x",c)]=string.char(c)
end

function X(s)
	return (string.gsub(s,"(..)",XT))
end

print(X"4c75612e6f7267")