Article View: news.software.nntp
Article #46453Re: Encoding binary data
From: Paul Martin
Date: Wed, 17 May 2000 00:00
Date: Wed, 17 May 2000 00:00
38 lines
2060 bytes
2060 bytes
In article <87bt2511sn.fsf@erlenstar.demon.co.uk>, Andrew Gierth wrote: >MIME base64 is designed for robustness not for maximum efficiency, the >64 data characters are chosen from the set that is least prone to >mangling when passing through foreign gateways (especially ones that >translate character sets). In an NNTP-only environment you can do much >better with a custom encoding algorithm. ASCII85 encoding is tempting, but you'd have to ensure that a "." doesn't fall on the first character of a line. (Spaces are ignored... or you can use the normal dot escape mechanism built into the news software.) In essence, take four octets of binary data, and convert them to a 32 bit value, and output the base85 equivalent of that number using the set of ASCII characters "!" (0) through to "u" (84). The special value of 0.0.0.0 is given the character "z" instead of "!!!!!". That results in a 25% expansion -- less for data that has runs of zeroes. One word about performance. ASCII85 will be slower running than MIME base64, as it's not as easy a number to divide by on a binary system. ASCII85 is more commonly known as "btoa", and there's plenty of source around on the net for that. Some tips for doing the mod85 stuff are on: http://www.machtech.com/articles/Vol.09/09.12/Dec93Challenge/ -- Paul Martin <pm@zetnet.net> at home, swap dash to dot to email.
Technical Details
Message-ID:
<slrn8i61u0.3qv.pm@manlap.zetnet.co.uk>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!not-for-mailReferences:
<3921BBF8.F251A540@unidata.ucar.edu> <87bt2511sn.fsf@erlenstar.demon.co.uk>Show Full Headers
Complete Article Headers
Message-ID: <slrn8i61u0.3qv.pm@manlap.zetnet.co.uk> Subject: Re: Encoding binary data Date: Wed, 17 May 2000 00:00:00 +0000 From: pm@nowster-zetnet.co.uk (Paul Martin) References: <3921BBF8.F251A540@unidata.ucar.edu> <87bt2511sn.fsf@erlenstar.demon.co.uk> 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!not-for-mail X-Deja-AN: 624698959 X-Trace: master.news.zetnet.net 958597101 32378 194.247.42.229 User-Agent: slrn/0.9.6.2 (Linux) Newsgroups: news.software.nntp