Skip to content

Instantly share code, notes, and snippets.

@randombrein
Created March 24, 2017 09:31
Show Gist options
  • Save randombrein/f5364c70f134064cf3a5bb4e70ba01f5 to your computer and use it in GitHub Desktop.
Save randombrein/f5364c70f134064cf3a5bb4e70ba01f5 to your computer and use it in GitHub Desktop.
function urlencode(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment