mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 12:28:21 +01:00
203 lines
4.5 KiB
HTML
203 lines
4.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
"http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
|
|
<head>
|
|
<title>LuaSocket: Network support for the Lua language</title>
|
|
<link rel="stylesheet" href="reference.css" type="text/css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<div class=header>
|
|
<hr>
|
|
<center>
|
|
<table summary="LuaSocket logo">
|
|
<tr><td align=center><a href="http://www.lua.org">
|
|
<img border=0 alt="LuaSocket" src="luasocket.png">
|
|
</a></td></tr>
|
|
<tr><td align=center valign=top>Network support for the Lua language
|
|
</td></tr>
|
|
</table>
|
|
<p class=bar>
|
|
<a href="home.html">home</a> ·
|
|
<a href="home.html#download">download</a> ·
|
|
<a href="introduction.html">introduction</a> ·
|
|
<a href="reference.html">reference</a>
|
|
</p>
|
|
</center>
|
|
<hr>
|
|
</div>
|
|
|
|
<!-- code +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<h2 id=code>Code</h2>
|
|
|
|
<p>
|
|
The <tt>code.lua</tt> 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
|
|
<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2045.txt">RFC
|
|
2045</a>,
|
|
URL escaping is described in
|
|
<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2396.txt">RFC
|
|
2396</a>.
|
|
</p>
|
|
|
|
<!-- base64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<p class=name id="base64">
|
|
socket.code.<b>base64(</b>content, single<b>)</b>
|
|
</p>
|
|
|
|
<p class=description>
|
|
Applies the Base 64 content coding to a string.
|
|
</p>
|
|
|
|
<p class=parameters>
|
|
<tt>Content</tt> is the string to be encoded.
|
|
If <tt>single</tt> is set to anything
|
|
but <tt>nil</tt>, the output is returned as a single
|
|
line, otherwise the function splits the content into 76 character long
|
|
lines after encoding.
|
|
</p>
|
|
|
|
<p class=result>
|
|
The function returns the encoded string.
|
|
</p>
|
|
|
|
<pre class=example>
|
|
code = socket.code.base64("diego:password")
|
|
-- code = "ZGllZ286cGFzc3dvcmQ="
|
|
</pre>
|
|
|
|
<!-- unbase64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<p class=name id="unbase64">
|
|
socket.code.<b>unbase64(</b>content<b>)</b>
|
|
</p>
|
|
|
|
<p class=description>
|
|
Removes the Base 64 content coding from a string.
|
|
</p>
|
|
|
|
<p class=parameters>
|
|
<tt>Content</tt> is the string to be decoded.
|
|
</p>
|
|
|
|
<p class=result>
|
|
The function returns the decoded string.
|
|
</p>
|
|
|
|
<!-- escape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<p class=name id="escape">
|
|
socket.code.<b>escape(</b>content<b>)</b>
|
|
</p>
|
|
|
|
<p class=description>
|
|
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.
|
|
</p>
|
|
|
|
<p class=parameters>
|
|
<tt>Content</tt> is the string to be encoded.
|
|
</p>
|
|
|
|
<p class=result>
|
|
The function returns the encoded string.
|
|
</p>
|
|
|
|
<pre class=example>
|
|
code = socket.code.escape("/#?;")
|
|
-- code = "%2f%23%3f%3b"
|
|
</pre>
|
|
|
|
<!-- unescape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<p class=name id="unescape">
|
|
socket.code.<b>unescape(</b>content<b>)</b>
|
|
</p>
|
|
|
|
<p class=description>
|
|
Removes the URL escaping content coding from a string.
|
|
</p>
|
|
|
|
<p class=parameters>
|
|
<tt>Content</tt> is the string to be decoded.
|
|
</p>
|
|
|
|
<p class=return>
|
|
The function returns the decoded string.
|
|
</p>
|
|
|
|
<!-- hexa +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<p class=name id="hexa">
|
|
socket.code.<b>hexa(</b>content<b>)</b>
|
|
</p>
|
|
|
|
<p class=description>
|
|
Applies the hexadecimal content coding to a string.
|
|
Each byte is encoded as the byte hexadecimal
|
|
representation of its integer value. <p>
|
|
</p>
|
|
|
|
<p class=parameters>
|
|
<tt>Content</tt> is the string to be encoded.
|
|
</p>
|
|
|
|
<p class=return>
|
|
The function returns the encoded string.
|
|
</p>
|
|
|
|
<pre class=example>
|
|
code = socket.code.hexa("\16\32\255")
|
|
-- code = "1020ff"
|
|
</pre>
|
|
|
|
<!-- unhexa +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<p class=name id="unhexa">
|
|
socket.code.<b>unhexa(</b>content<b>)</b>
|
|
</p>
|
|
|
|
<p class=description>
|
|
Removes the hexadecimal content coding from a string.
|
|
</p>
|
|
|
|
<p class=parameters>
|
|
<tt>Content</tt> is the string to be decoded.
|
|
</p>
|
|
|
|
<p class=return>
|
|
The function returns the decoded string.
|
|
</p>
|
|
|
|
<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
|
|
|
<div class=footer>
|
|
<hr>
|
|
<center>
|
|
<p class=bar>
|
|
<a href="home.html">home</a> ·
|
|
<a href="home.html#down">download</a> ·
|
|
<a href="introduction.html">introduction</a> ·
|
|
<a href="reference.html">reference</a>
|
|
</p>
|
|
<p>
|
|
<small>
|
|
Last modified by Diego Nehab on <br>
|
|
Sat Aug 9 01:00:41 PDT 2003
|
|
</small>
|
|
</p>
|
|
</center>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|