From 982781f1464c9b7a8133130433f83dbf1f59a2c0 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Sun, 31 Aug 2003 01:00:15 +0000 Subject: LuaSocket 2.0 User's Manual. --- doc/code.html | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 doc/code.html (limited to 'doc/code.html') diff --git a/doc/code.html b/doc/code.html new file mode 100644 index 0000000..45fd21a --- /dev/null +++ b/doc/code.html @@ -0,0 +1,202 @@ + + + + +LuaSocket: Network support for the Lua language + + + + + + + +
+
+
+ + + +
+LuaSocket +
Network support for the Lua language +
+

+home · +download · +introduction · +reference +

+
+
+
+ + + +

Code

+ +

+The code.lua module offers routines to convert back and forth +some common types of content encoding, including Base 64 and URL +escaping. Base 64 is described in +RFC +2045, +URL escaping is described in +RFC +2396. +

+ + + +

+socket.code.base64(content, single) +

+ +

+Applies the Base 64 content coding to a string. +

+ +

+Content is the string to be encoded. +If single is set to anything +but nil, the output is returned as a single +line, otherwise the function splits the content into 76 character long +lines after encoding. +

+ +

+The function returns the encoded string. +

+ +
+code = socket.code.base64("diego:password")
+-- code = "ZGllZ286cGFzc3dvcmQ="
+
+ + + +

+socket.code.unbase64(content) +

+ +

+Removes the Base 64 content coding from a string. +

+ +

+Content is the string to be decoded. +

+ +

+The function returns the decoded string. +

+ + + +

+socket.code.escape(content) +

+ +

+Applies the URL escaping content coding to a string +Each byte is encoded as a percent character followed +by the two byte hexadecimal representation of its integer +value. +

+ +

+Content is the string to be encoded. +

+ +

+The function returns the encoded string. +

+ +
+code = socket.code.escape("/#?;")
+-- code = "%2f%23%3f%3b"
+
+ + + +

+socket.code.unescape(content) +

+ +

+Removes the URL escaping content coding from a string. +

+ +

+Content is the string to be decoded. +

+ +

+The function returns the decoded string. +

+ + + +

+socket.code.hexa(content) +

+ +

+Applies the hexadecimal content coding to a string. +Each byte is encoded as the byte hexadecimal +representation of its integer value.

+

+ +

+Content is the string to be encoded. +

+ +

+The function returns the encoded string. +

+ +
+code = socket.code.hexa("\16\32\255")
+-- code = "1020ff"
+
+ + + +

+socket.code.unhexa(content) +

+ +

+Removes the hexadecimal content coding from a string. +

+ +

+Content is the string to be decoded. +

+ +

+The function returns the decoded string. +

+ + + + + + + -- cgit v1.2.3-55-g6feb