🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #53576

Re: yEncode: A quick and dirty 8 bit encoding method

#53576
From: J.B. Moreno
Date: Tue, 31 Jul 2001 18:06
76 lines
4326 bytes
In article <3b67be46.14498597@127.0.0.1>, 
 The Archiver <archiver@i3w.com> wrote:

> Please read my other message (yEnc - 8 bit encoding) which is related
> to this text. Thanks.
> 
> - - - - - snip - - - - - 
> 
> yEncode - A quick and dirty encoding for binaries
> --------------------------------------------------
> Version 1.0 - 31-July-2001 - by Juergen@Helbing.de

If you think it might change you need to include a version number as
part of the overhead.

-snip-
>    Principle
>    --------
> The principle of encoding is really simple: A few special characters
> are reserved from the 8-bit-charset, one character is used as escape
> character to encode the 'critical' ones.
> Critical characters are usually: NULL, TAB, CR, LF.
>   (The list could be easily extended - if necessary)
> As escape character we use the '=' equal sign.

Tab's shouldn't be a problem -- if you were using an existing format
like QP which is already being used for text message, it might be a
problem, but as you're not...

> A lot of binaries are using a lot of NULL characters - so the entire
> character table is rotated by 42:  0-> 42, 1->43, .... 255 -> 41
> So just a few exotic bytes will be encoded with the escape character.
> And these 'exotic' codes have usually a probability of 0.4%.
> With 5 'critical' characters up to 2% of overhead are produced.

IME nulls especially often run in sequence, which suggests that the
best thing to do is to add some minimal compression in order to avoid
the problem with overescaping.  And since nulls are what you'd be most
likely to escape, you'll get better milage out of compressing than
rotating.

Perhaps something like: '=' is the escape, followed by '1' for null,
'2' for CR, '3' for LF and '=' for an equal sign, otherwise it's a
single base 192 number (where zero equals 0x40) followed by the
(potentially escaped) byte to be expanded.  You'd want to change your
boundary to '=-' or something instead of '=y' but that shouldn't be a
problem. 

That means that =A=1 means 2 nulls. Notice this means that your worse
case for escaping is a 1 character penalty per escaped character, and
your average and best cases are much better...

I was talking to Brian Clark about the QP-Lite encoding and he pointed
out that it's good to have various types of error checking.  You are
including a byte count which is good, how about extending that a bit
and including a single (base 192) number at the beginning of each line
indicating either the number of characters on the wire or the number of
characters that the line expands to (depending upon how you want to do
things).  That would limit your line length to 192 (before or after
encoding) but would give the ability to detect in-transit damage (it
also nicely avoids the problem of having to escape '.' at the beginning
of lines).

>    Headers and Trailers
>    --------------------
> It might be possible to embedd such an encoding into the MIME standard
> - but this takes a long time - and that standard does not add value.

Actually it does -- if you use MIME sections then programs that are
totally unaware of your format can extract the information and save it
to disk for a standalone decoder to deal with.  This allows a decoder
to only worry about decoding, and not extracting.

-- 
J.B. Moreno
Technical Details
Message-ID: <310720011406256023%planb@newsreaders.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.cidera.com!feed1.newsreader.com!news2.newsreader.com!flame.newsreader.com!planb
References: <3b67be46.14498597@127.0.0.1>

Show Full Headers
Complete Article Headers
Message-ID: <310720011406256023%planb@newsreaders.com>
Subject: Re: yEncode: A quick and dirty 8 bit encoding method
Date: Tue, 31 Jul 2001 14:06:25 -0400
From: "J.B. Moreno" <planb@newsreaders.com>
References: <3b67be46.14498597@127.0.0.1>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.cidera.com!feed1.newsreader.com!news2.newsreader.com!flame.newsreader.com!planb
Newsgroups: news.software.nntp
Organization: bofh wannabe
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: 8bit
User-Agent: Thoth/1.2.4 (Carbon/OS X)
X-Trace: flame.newsreader.com w7ipII,.BDpauMzSoVnNwmCTbZ8gT97bEIelMQD7=.3dfh
Lines: 75