<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://www.tcl.tk/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Thu May 17 04:10:18 GMT 2012 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='317'>
<header><title>Extend binary Ensemble with Binary Encodings</title><author address="mailto:patthoyts@users.sourceforge.net">Pat Thoyts</author><status type='project' state='final' tclversion="8.6" vote='after'>$Revision: 1.5 $</status><history></history><created day='3' month='may' year='2008' /><keyword>base64 uuencode hex {transfer encoding}</keyword></header>
<abstract>This TIP extends the <emph style="bold">binary</emph> command with implementations in C of commonly used binary encodings. In particular the <emph style="italic">base64</emph> encoding is implemented but the Tcl ensemble scheme <tipref type="text" tip="112"/> can be used to provide simple extension of the implemented formats.</abstract>
<body><section title="Specification">
<para>The <emph style="bold">binary</emph> command ensemble will be extended to include two new subcommands, <emph style="bold">encode</emph> and <emph style="bold">decode</emph>. Each subcommand will accept two arguments. The first is the name of an encoding format and the second is the data to be operated upon.</para>
<quote><emph style="bold">binary encode</emph> <emph style="italic">format ?-option value ...? data</emph></quote>
<quote><emph style="bold">binary decode</emph> <emph style="italic">format ?-option value ...? data</emph></quote>
<para>In keeping with the nature of the <emph style="bold">binary</emph> command, the <emph style="italic">data</emph> argument is treated as a byte array. This means that users should ensure their data is already in a suitable character encoding before applying a binary encoding. This is already a requirement for other implementations of this functionality (e.g. the tcllib and Trf packages).</para>
<para>The initial set of binary encodings consists of <emph style="bold">base64</emph>, <emph style="bold">uuencode</emph> and <emph style="bold">hex</emph>. The implementation of the <emph style="bold">encode</emph> and <emph style="bold">decode</emph> subcommands will make use of the Tcl ensemble command mechanism (<tipref type="text" tip="112"/>) and will therefore be extensible via the ensemble mechanism.</para>
</section>
<section title="Reference Implementation">
<para>A patch against the Tcl HEAD (8.6) is located at <url ref="http://sf.net/tracker/?func=detail&amp;aid=1956530&amp;group_id=10894&amp;atid=310894"/></para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>

