-- ********************************************************************** -- * Html Encoding utilities -- * -- * version 0.1 -- * -- * (c) 2005 Hi-Project Ltd. -- ********************************************************************** ENCODING = "UTF-8" require"utf8" -- UTF utilities ----------------- function str_encode(s) if s==nil then return "" end if ENCODING == "UTF-8" then return utf8.encode(s) or "" else return s end end function str_decode(s) if s==nil then return "" end if ENCODING == "UTF-8" then return utf8.decode(s) or "" else return s end end function table_decode(t) if t==nil then return {} end if ENCODING == "UTF-8" then table.foreach(t,function(k,v) if type(v)=="string" then t[k] = utf8.decode(v) or "" end end) end return t end function table_encode(t) if t==nil then return {} end if ENCODING == "UTF-8" then table.foreach(t,function(k,v) if type(v)=="string" then t[k] = utf8.encode(v) or "" end end) end return t end