http://tcllib.sourceforge.net/doc/yencode.html
This package provides a Tcl-only implementation of the yEnc file encoding. This is a recently introduced method of encoding binary files for transmission through Usenet. This encoding packs binary data into a format that requires an 8-bit clean transmission layer but that escapes characters special to the NNTP posting protocols. See http://www.yenc.org/ for details concerning the algorithm.
See also uudecode, base64 for related functionality (other encoders)
Pat Thoyts wrote in the comp.lang.tcl newsgroup: I found out about yenc encoding ... and it's not the same as uuencoding. Hopefully you are not trying to decode yenc data using the uuencode/uudecode code :) If you want a tcl yenc decoder I'm going to add one to tcllib's base64 module shortly.
LV and in fact Pat has added (to the latest base64 module of tcllib) a yencode set of functions.
In the meantime here is the core of this method:
namespace eval yencode {} ;# added by RS proc yencode::yEncode {s} { set r {} binary scan $s c* d foreach {c} $d { set v [expr {($c + 42) % 256}] if {$v == 0x00 || $v == 0x09 || $v == 0x0A || $v == 0x0D || $v == 0x3D} { append r "=" set v [expr {($v + 42) % 256}] } append r [format %c $v] } return $r } proc yencode::yDecode {s} { set r {} set esc 0 binary scan $s c* d foreach c $d { if {$c == 61 && $esc == 0} { set esc 1 continue } set v [expr {($c - 42) % 256}] if {$esc} { set v [expr {($v - 42) % 256}] set esc 0 } append r [format %c $v] } return $r }
Someone recently posted a question on comp.lang.tcl asking about yenc multi-part support in Tcl; anyone know of such code?
[ Category Package, subset Tcllib | Arts and crafts of Tcl-Tk programming ]