TIP #317: Extend binary Ensemble with Binary Encodings
_____________________________________________________________________________
TIP:	317
Title:	Extend binary Ensemble with Binary Encodings
Version:	$Revision: 1.5 $
Authors:	Pat Thoyts <patthoyts@users.sourceforge.net>
State:	Final
Type:	Project
Tcl-Version:	8.6
Vote:	Done
Created:	Sat May 03 00:00:00 UTC 2008
Keywords:	base64, uuencode, hex, transfer encoding
Abstract
This TIP extends the binary command with implementations in C of commonly used binary encodings. In particular the base64 encoding is implemented but the Tcl ensemble scheme [112] can be used to provide simple extension of the implemented formats.
Specification
The binary command ensemble will be extended to include two new subcommands, encode and decode. 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.
binary encode format ?-option value ...? data
binary decode format ?-option value ...? data
In keeping with the nature of the binary command, the data 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).
The initial set of binary encodings consists of base64, uuencode and hex. The implementation of the encode and decode subcommands will make use of the Tcl ensemble command mechanism ([112]) and will therefore be extensible via the ensemble mechanism.
Reference Implementation
A patch against the Tcl HEAD (8.6) is located at http://sf.net/tracker/?func=detail&aid=1956530&group_id=10894&atid=310894
Copyright
This document has been placed in the public domain.
_____________________________________________________________________________
Colophon
TIP AutoGenerator - written by Donal K. Fellows