Skip to content

Instantly share code, notes, and snippets.

@notsobad
Created July 16, 2015 16:41
Show Gist options
  • Save notsobad/be72f5abef0b5fffe7fd to your computer and use it in GitHub Desktop.
Save notsobad/be72f5abef0b5fffe7fd to your computer and use it in GitHub Desktop.
function escapeNonePrintable(_)
local fmt = string.format
return string.gsub(_, "[%z\1-\31,\127-\255]", function (x)
return fmt("\\%d",string.byte(x))
end)
end
print(escapeNonePrintable("a\tb\10c"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment