Created
July 24, 2014 18:52
-
-
Save yi/01e3ab762838d567e65d to your computer and use it in GitHub Desktop.
lua hex <= => string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function string.fromhex(str) | |
return (str:gsub('..', function (cc) | |
return string.char(tonumber(cc, 16)) | |
end)) | |
end | |
function string.tohex(str) | |
return (str:gsub('.', function (c) | |
return string.format('%02X', string.byte(c)) | |
end)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very nice !