[Zrouter-src] ZRouter.org: push to ZRouter profiles/lua_web_ui/files/etc/www/l...
zrouter-src at zrouter.org
zrouter-src at zrouter.org
Mon Sep 24 11:23:51 UTC 2012
details: http://zrouter.org/hg/zrouter//rev/d7b0ddec1929
changeset: 464:d7b0ddec1929
user: Aleksandr Rybalko <ray at ddteam.net>
date: Mon Sep 24 14:14:50 2012 +0300
description:
URL encode/decode helpers.
diffstat:
profiles/lua_web_ui/files/etc/www/lib/urlXxcode.lua | 22 +++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diffs (26 lines):
diff -r 24007794e57a -r d7b0ddec1929 profiles/lua_web_ui/files/etc/www/lib/urlXxcode.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/profiles/lua_web_ui/files/etc/www/lib/urlXxcode.lua Mon Sep 24 14:14:50 2012 +0300
@@ -0,0 +1,22 @@
+--
+-- Utility function: URL encoding function
+--
+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
+
+--
+-- Utility function: URL decode function
+--
+function urlDecode(str)
+ str = string.gsub (str, "+", " ")
+ str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end)
+ str = string.gsub (str, "\r\n", "\n")
+ return str
+end
More information about the Zrouter-src
mailing list